By GokiSoft.com|
15:55 28/10/2021|
C Sharp
[Video] [Examination] C# - Chương trình quản lý đội thi TechWiz toàn cầu Apptech Ấn Độ - C#
[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 ShowInfo();
class Program
{
static void Main(string[] args)
{
//1. Khai bao
List<Group> groupList = new List<Group>();
Random random = new Random();
int N = random.Next(2) + 2;
//2. Nhap thong tin
for(int i=0;i<N;i++)
{
Group group = new Group();
group.Input();
groupList.Add(group);
}
//3. Quan ly tat display cua group -> delegate
ShowInfo displayAll = null;
foreach(Group g in groupList)
{
displayAll += g.Display;
}
displayAll();
}
}
}
#Project.cs
using System;
namespace BT2312
{
public class Project
{
public string Name { get; set; }
public string Type { get; set; }
public Project()
{
}
public Project(string name, string type)
{
Name = name;
Type = type;
}
public void Input()
{
Console.WriteLine("Nhap ten du an: ");
Name = Console.ReadLine();
Console.WriteLine("Nhap loai du an: ");
int choose;
while(true)
{
Console.WriteLine("1. Development & Design Website");
Console.WriteLine("2. Website Developer");
Console.WriteLine("3. Application Developer");
Console.WriteLine("Chon: ");
try
{
choose = int.Parse(Console.ReadLine());
switch(choose)
{
case 1:
Type = "Development & Design Website";
break;
case 2:
Type = "Website Developer";
break;
default:
Type = "Application Developer";
break;
}
break;
}
catch
{
Console.WriteLine("Nhap lai!!!");
}
}
}
public void Display()
{
Console.WriteLine("Ten: {0}, loai: {1}", Name, Type);
}
}
}
#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();
}
}
}
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)