[Examination] C# - Chương trình quản lý đội thi TechWiz toàn cầu Apptech Ấn Độ - C#
Trong cuộc thi Techwiz toàn cầu do Aptech Ấn Độ tổ chức. Có rất nhiều các đội ở các trung tâm Aptech trên toàn cầu cùng tham gia. Bạn được yêu cầu viết chương trình quản lý thông tin đội chơi và thông tin dự án của từng đội.
Yêu cầu:
1) Tạo lớp đối tượng Project gồm các trường thông tin: string name (tên đề tài), string projectType: Nhóm dự án (group chỉ nhận 3 giá trị là Development & Design Website, Website Developer, Application Developer) - 1 điểm
2) Tạo lớp đối tượng Group gồm các thuộc tính: string name (tên nhóm), string center: tên trung tâm aptech, project (kiểu dữ liệu là Project) - 1 điểm
Viết getter/setter cho tất cả các thuộc tính của lớp đối tượng - 1 điểm
Viết hàm Input, Display của đối tượng trên - 2 điểm
Tạo class Program có chưa 1 method Main. Yêu cầu khai báo mảng List<Group> groupList. Yêu cầu nhập vào ngẫu nhiên N nhóm (N có giá trị từ 2 tới 10) - 5 điểm
Tạo 1 delegate như sau
delegate void ShowInfor();
Khai báo 1 đối tượng delegate ShowInfor -> Thực hiện quản lý tất cả các phương thức Display() của tất cả các đối tượng Project trong đối tượng này. Yêu cầu gọi thực thi delegate vừa được tạo ra. - 5 điểm
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)
![hainguyen [T2008A]](https://www.gravatar.com/avatar/32855ce6db55d60134d830aee06b41e5.jpg?s=80&d=mm&r=g)
hainguyen
2021-06-04 09:21:19
#Group.cs
using System;
using System.Collections.Generic;
using System.Text;
namespace BaiThiThucHanh
{
class Group
{
public string name { get; set; }
public string center { get; set; }
public Project project { get; set; }
public Group() { }
public Group(string name, string center)
{
this.name = name;
this.center = center;
}
public void input()
{
Console.WriteLine("Nhap name: ");
name = Console.ReadLine();
Console.WriteLine("Nhap center: ");
center = Console.ReadLine();
project = new Project();
project.input();
}
public void display()
{
Console.WriteLine("name: = {0}", name);
Console.WriteLine("center: = {0]", center);
project.display();
}
}
}
#Program.cs
using System;
using System.Collections.Generic;
namespace BaiThiThucHanh
{
class Program
{
public delegate void ShowInfor();
static void Main(string[] args)
{
List<Group> grouplist = new List<Group>();
List<ShowInfor> showInforlist = new List<ShowInfor>();
Console.WriteLine("Nhap N nhom:");
int N = int.Parse(Console.ReadLine());
for (int i = 1; i <= N; i++)
{
Group group = new Group();
group.input();
grouplist.Add(group);
showInforlist.Add(group.project.display);
}
foreach (ShowInfor s in showInforlist)
{
s();
}
}
}
}
#Project.cs
using System;
using System.Collections.Generic;
using System.Text;
namespace BaiThiThucHanh
{
class Project
{
public string name { get; set; }
public string group { get; set; }
public Project() { }
public Project(string name, string group)
{
this.name = name;
this.group = group;
}
public void input()
{
Console.WriteLine("Nhap name:");
name = Console.ReadLine();
Console.WriteLine("Chon 1 trong 3 de tai:");
Console.WriteLine("1. Development & Design Website");
Console.WriteLine("2. Website Developer");
Console.WriteLine("3. Application Developer");
int choose = int.Parse(Console.ReadLine());
if (choose == 1)
{
group = "Development & Design Website";
}
if (choose == 2)
{
group = "Website Developer";
}
if (choose == 3)
{
group = "Application Developer";
}
}
public void display()
{
Console.WriteLine("name: = {0}", name);
Console.WriteLine("group: = {0}", group);
}
}
}
![Bùi Văn Mạnh [T2008A]](https://www.gravatar.com/avatar/17e9c94870c94e61c9203ee31dccf01c.jpg?s=80&d=mm&r=g)
Bùi Văn Mạnh
2021-06-04 09:20:10
using System;
namespace TechWiz
{
class Project
{
public string name { get; set; }
public string group { get; set; }
public Project()
{
}
public void Input()
{
Console.WriteLine("Ten de tai:");
name = Console.ReadLine();
Console.WriteLine("Chon 1 trong 3 nhom:");
Console.WriteLine("1.Development & Design Website");
Console.WriteLine("2.Website Developer");
Console.WriteLine("3.Application Developer");
int chon = int.Parse(Console.ReadLine());
if(chon == 1)
{
group = "Development & Design Website";
}
if(chon == 2)
{
group = "Website Developer";
}
if(chon == 3)
{
group = "Application Developer";
}
}
public void Display()
{
Console.WriteLine("Ten de tai: {0}", name);
Console.WriteLine("Nhom du an: {0}", group);
}
}
}
![Nguyễn Hữu Hiếu [T2008A]](https://www.gravatar.com/avatar/ca2884508b617fee77f000c7d99c219d.jpg?s=80&d=mm&r=g)
Nguyễn Hữu Hiếu
2021-06-04 09:20:02
using System;
using System.Collections.Generic;
namespace exam
{
public delegate void ShowInfor();
class Program
{
static event ShowInfor calEvent = null;
static void Main(string[] args)
{
Console.WriteLine("Nhap n (n = 2 - 10): ");
int num = int.Parse(Console.ReadLine());
List<Group> listGroup = new List<Group>(num);
for(int i = 0; i < num;i++)
{
Group g = new Group();
g.Input();
listGroup.Add(g);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace exam
{
class Project
{
public string Name { get; set; }
public string Group { get; set; }
public Project() {
}
public Project(string Name, string Group)
{
this.Name = Name;
this.Group = Group;
}
public void Input()
{
Console.WriteLine("Nhap ten de tai: ");
Name = Console.ReadLine();
Console.WriteLine("Nhap nhom du an: ");
Group = Console.ReadLine();
}
public void Display()
{
Console.WriteLine("Ten de tai: {0}, Nhom du an: {1}", Name, Group);
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace exam
{
class Group
{
string Name { get; set; }
string Center { get; set; }
Project p { get; set; }
public Group() { }
public Group(string Name, string Center, Project p)
{
this.Name = Name;
this.Center = Center;
}
public void Input()
{
Console.WriteLine("Nhap ten nhom: ");
Name = Console.ReadLine();
Console.WriteLine("Nhap ten trung tam: ");
Center = Console.ReadLine();
}
public void Display()
{
Console.WriteLine("Ten nhom: {0}, Ten trung tam: {1}", Name, Center);
}
}
}
![Nguyên Phấn Đông [T2008A]](https://www.gravatar.com/avatar/c9c4f8f79ce35b9224637b6cc5fbe5c4.jpg?s=80&d=mm&r=g)
Nguyên Phấn Đông
2021-06-04 09:19:28
#Group.cs
using System;
namespace TechWiz
{
class Group
{
public string name { get; set; }
public string center { get; set; }
public Project project { get; set; }
public Group()
{
}
public void Input()
{
Console.WriteLine("Ten nhom:");
name = Console.ReadLine();
Console.WriteLine("Ten trung tam:");
center = Console.ReadLine();
project = new Project();
project.Input();
}
public void Display()
{
Console.WriteLine("Ten nhom: {0}", name);
Console.WriteLine("Ten trung tam: {0}", center);
project.Display();
}
}
}
#Program.cs
using System;
using System.Collections.Generic;
namespace TechWiz
{
class Program
{
List<showInfor> list = new List<showInfor>();
List<Group> groupList = new List<Group>();
public delegate void showInfor();
static void Main(string[] args)
{
while (true)
{
Console.WriteLine("Nhập N: ");
int N = 2;
try
{
N = Int32.Parse(Console.ReadLine());
if (x >= 2 && x <= 10) break;
else Console.WriteLine("Yeu cau nhap lai x (so nguyen, trong khoang 2 - 10) = ");
}
catch (Exception)
{
Console.WriteLine("Yeu cau nhap lai x (so nguyen, trong khoang 2 - 10) = ");
}
}
for (int i = 1; i <= N; i++)
{
Group group = new Group();
group.Input();
groupList.Add(group);
list.Add(group.project.Display);
}
foreach (showInfor name in list)
{
name();
}
}
}
}
#Project.cs
using System;
namespace TechWiz
{
class Project
{
public string name { get; set; }
public string group { get; set; }
public Project()
{
}
public void Input()
{
Console.WriteLine("Ten de tai:");
name = Console.ReadLine();
Console.WriteLine("Chon 1 trong 3 nhom:");
Console.WriteLine("1.Development & Design Website");
Console.WriteLine("2.Website Developer");
Console.WriteLine("3.Application Developer");
int chon = int.Parse(Console.ReadLine());
if(chon == 1)
{
group = "Development & Design Website";
}
if(chon == 2)
{
group = "Website Developer";
}
if(chon == 3)
{
group = "Application Developer";
}
}
public void Display()
{
Console.WriteLine("Ten de tai: {0}", name);
Console.WriteLine("Nhom du an: {0}", group);
}
}
}
![Triệu Văn Lăng [T2008A]](https://www.gravatar.com/avatar/1348e3562c6492c26f796cb1f45982a1.jpg?s=80&d=mm&r=g)
Triệu Văn Lăng
2021-06-04 09:18:17
#Group.cs
using System;
using System.Collections.Generic;
using System.Text;
namespace Exam
{
class Group
{
public string Name { get; set; }
public string Center { get; set; }
public List<Project> proList { get; set; }
public Group()
{
proList = new List<Project>();
}
public Group(string Name, string Center)
{
this.Name = Name;
this.Center = Center;
}
public void input()
{
Console.WriteLine("Nhap ten nhom: ");
Name = Console.ReadLine();
Console.WriteLine("Nhap ten trung tam: ");
Center = Console.ReadLine();
inputProject(proList);
}
public void inputProject(List<Project> proList)
{
Project project = new Project();
project.input();
proList.Add(project);
}
public void display()
{
Console.WriteLine("Ten nhom: {0}, Ten trung tam: {1}", Name, Center);
foreach (Project project in proList)
{
project.display();
}
}
}
}
#Program.cs
using System;
using Exam;
using System.Collections.Generic;
namespace Exam
{
class Program
{
public delegate void ShowInfor();
static List<Group> groupList = new List<Group>();
static void Main(string[] args)
{
Console.WriteLine("Nhap ngau nhien N nhom: ");
int n = Convert.ToInt32(Console.ReadLine());
if(n < 2 || n > 10)
{
Console.WriteLine("N co gia tri tu 2 den 10");
}
for(int i = 0; i < n; i++)
{
Console.WriteLine("Nhap thong tin nhom thu {0}: ", i + 1);
Group group = new Group();
group.input();
groupList.Add(group);
}
Console.WriteLine("Danh sach cac nhom thi");
foreach(Group gr in groupList)
{
gr.display();
}
}
}
}
#Project.cs
using System;
using System.Collections.Generic;
using System.Text;
namespace Exam
{
class Project
{
public string Name { get; set; }
public string Group { get; set; }
public Project()
{
}
public Project(string Name, string Group)
{
this.Name = Name;
this.Group = Group;
}
public void input()
{
Console.WriteLine("Nhap ten project: ");
Name = Console.ReadLine();
Console.WriteLine("Chon nhom du an:");
Console.WriteLine("1. Development & Design Website");
Console.WriteLine("2. Website Developer");
Console.WriteLine("3. Application Developer");
int choose = Convert.ToInt32(Console.ReadLine());
switch(choose)
{
case 1:
Group = "Development & Design Website";
break;
case 2:
Group = "Website Developer";
break;
case 3:
Group = "Application Developer";
break;
default:
Console.WriteLine("Chon lai!!!");
break;
}
}
public void display()
{
Console.WriteLine("Ten Project: {0}, Nhom du an: {1}", Name, Group);
}
}
}
![Bùi Văn Mạnh [T2008A]](https://www.gravatar.com/avatar/17e9c94870c94e61c9203ee31dccf01c.jpg?s=80&d=mm&r=g)
Bùi Văn Mạnh
2021-06-04 09:18:02
using System;
namespace TechWiz
{
class Group
{
public string name { get; set; }
public string center { get; set; }
public Project project { get; set; }
public Group()
{
}
public void Input()
{
Console.WriteLine("Ten nhom:");
name = Console.ReadLine();
Console.WriteLine("Ten trung tam:");
center = Console.ReadLine();
project = new Project();
project.Input();
}
public void Display()
{
Console.WriteLine("Ten nhom: {0}", name);
Console.WriteLine("Ten trung tam: {0}", center);
project.Display();
}
}
}
![Do Trung Duc [T2008A]](https://www.gravatar.com/avatar/2973ac07124f066b4605c535e8d39a99.jpg?s=80&d=mm&r=g)
Do Trung Duc
2021-06-04 09:16:48
using System;
using System.Collections.Generic;
using System.Text;
namespace ExamFinal
{
class Project
{
public string Name { get; set; }
string _Group;
public string Group
{
get
{
return _Group;
}
set
{
if (value == "Development & Design Website" || value == "Website Developer" || value == "Application Developer")
{
_Group = value;
}
}
}
public Project() { }
public Project(string Name, string Group)
{
this.Name = Name;
this.Group = Group;
}
public void Input()
{
Console.WriteLine("Nhap ten du an:");
Name = Console.ReadLine();
Console.WriteLine("Nhap nhom du an:");
Group = Console.ReadLine();
}
public void Display()
{
Console.WriteLine("Ten du an: {0}, Nhom du an: {1}", Name, Group);
}
}
}
![Do Trung Duc [T2008A]](https://www.gravatar.com/avatar/2973ac07124f066b4605c535e8d39a99.jpg?s=80&d=mm&r=g)
Do Trung Duc
2021-06-04 09:16:36
using System;
using System.Collections.Generic;
using System.Text;
namespace ExamFinal
{
class Group
{
public string Name { get; set; }
public string Center { get; set; }
public Project Project { get; set; }
public Group() { }
public Group(string Name, string Center, Project Project)
{
this.Name = Name;
this.Center = Center;
this.Project = Project;
}
public void Input()
{
Console.WriteLine("Nhap ten nhom:");
Name = Console.ReadLine();
Console.WriteLine("Nhap ten trung tam:");
Center = Console.ReadLine();
Console.WriteLine("Nhap thong tin du an:");
Project = new Project();
Project.Input();
}
public void Display()
{
Console.WriteLine("Ten nhom: {0}, Ten Trung Tam: {1}", Name, Center);
Console.WriteLine("Thong tin ve du an cua nhom nhu sau:");
Project.Display();
}
}
}
![Do Trung Duc [T2008A]](https://www.gravatar.com/avatar/2973ac07124f066b4605c535e8d39a99.jpg?s=80&d=mm&r=g)
Do Trung Duc
2021-06-04 09:16:25
using System;
using System.Collections.Generic;
namespace ExamFinal
{
class Program
{
public delegate void ShowInfor();
static List<Group> ListGroup = new List<Group>();
static void Main(string[] args)
{
List<Group> ListGroup = new List<Group>();
Console.WriteLine("Nhap so luong nhom muon them:");
int N = Int32.Parse(Console.ReadLine());
for(int i = 0; i < N; i++)
{
Console.WriteLine("Nhap thong tin nhom thu {0}", i + 1);
Group group = new Group();
group.Input();
ListGroup.Add(group);
}
Console.WriteLine("Thong tin tat ca cac du an tham gia cuoc thi nhu sau:");
ShowInfor showInfor = new ShowInfor(DisplayAllProject);
showInfor();
}
static void DisplayAllProject()
{
foreach(Group group in ListGroup)
{
group.Project.Display();
}
}
}
}
![Nguyễn Tuấn Hùng [T2008A]](https://www.gravatar.com/avatar/74c1ca6934aee629f926008762ab4ef5.jpg?s=80&d=mm&r=g)
Nguyễn Tuấn Hùng
2021-06-04 09:12:03
#group.cs
using System;
using System.Collections.Generic;
using System.Text;
namespace Cshap_test
{
class group
{
public string name { get; set; }
public string center { get; set; }
Console.WriteLine(" Nhap Ten Nhom :")
string groupname = Console.ReadLine();
Console.WriteLine(" Ten De Tai : " + groupname );
Console.WriteLine(" Nhap Ten center :")
string groupcenter = Console.ReadLine();
Console.WriteLine(" Ten De Tai : " + groupcenter );
}
}
#Program.cs
using System;
namespace Cshap_test
{
class Program
{
static void Main(string[] args)
{
}
}
}
#project.cs
using System;
namespace Cshap_test
{
class project
{
public string name { get; set; }
public string group { get; set; }
Console.WriteLine(" Nhap Ten De Tai :")
string projectname = Console.ReadLine();
Console.WriteLine(" Ten De Tai : " + ProjectName );
Console.WriteLine(" Nhap Ten Nhom :")
string projectgroup = Console.ReadLine();
Console.WriteLine(" Ten De Tai : " + projectgroup );
}
}