By GokiSoft.com|
19:10 26/10/2021|
C Sharp
[Share Code] [Examination] C# - Chương trình quản lý đội thi TechWiz toàn cầu Apptech Ấn Độ - C# - C2010L
[Examination] C# - Chương trình quản lý đội thi TechWiz toàn cầu Apptech Ấn Độ - C#
#Program.cs
using System;
using System.Collections.Generic;
namespace BT2312
{
delegate void ShowInfor();
class Program
{
static void Main(string[] args)
{
//Khai bao mang groupList
List<Group> groupList = new List<Group>();
//Sinh ngau nhien N phan tu Group
Random random = new Random();
int n = random.Next(2) + 2;
Console.WriteLine("So nhom can them: {0}", n);
//Nhap du lieu cho mang N phan tu tren
for(int i=0;i<n;i++)
{
Group group = new Group();
group.Input();
groupList.Add(group);
}
//Khai bao doi tuong delegate
ShowInfor showInfor = null;
//Nhom ham Display cua tat ca doi tuong groupList -> vao delegate
foreach (Group g in groupList)
{
showInfor += g.Display;
}
//Thuc thi goi delegate
showInfor();
}
}
}
#Group.cs
using System;
namespace BT2312
{
public class Group
{
public string Name { get; set; }
public string Center { get; set; }
public Project MyProject { get; set; }
public Group()
{
MyProject = new Project();
}
public void Input()
{
Console.WriteLine("================================");
Console.WriteLine("Nhap ten nhom: ");
Name = Console.ReadLine();
Console.WriteLine("Nhap trung tam: ");
Center = Console.ReadLine();
MyProject.Input();
}
public void Display()
{
Console.WriteLine("Ten nhom: {0}, trung tam: {1}", Name, Center);
MyProject.Display();
}
}
}
#Project.cs
using System;
namespace BT2312
{
public class Project
{
public string Name { get; set; }
public string ProjectType { get; set; }
public Project()
{
}
public void Input()
{
Console.WriteLine("Nhap ten: ");
Name = Console.ReadLine();
Console.WriteLine("Chon loai de tai: ");
string[] options = { "Development & Design Website",
"Website Developer", "Application Developer" };
for(int i=1;i<=options.Length;i++)
{
Console.WriteLine("{0}. {1}", i, options[i-1]);
}
Console.WriteLine("Chon: ");
int choose = int.Parse(Console.ReadLine());
if(choose < 1 || choose > options.Length)
{
choose = options.Length;
}
ProjectType = options[choose - 1];
}
public void Display()
{
Console.WriteLine("Ten: {0}, loai de tai: {1}", Name, ProjectType);
}
}
}
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)