By GokiSoft.com| 15:56 28/10/2021|
C Sharp

[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





Phản hồi từ học viên

5

(Dựa trên đánh giá ngày hôm nay)

Hoàng Thiện Thanh [community,AAHN-C2009G]
Hoàng Thiện Thanh

2021-10-07 09:06:50


#Group.cs


using System;
using System.Collections.Generic;
using System.Text;

namespace T2008A
{
    public class Group
    {
        public string Name { get; set; }
        public string Center { get; set; }
        public Project Project { get; set; }

        public Group()
        {
            this.Project = new Project();
        }

        public Group(string Name, string Center)
        {
            this.Name = Name;
            this.Center = Center;
            this.Project = new Project();
        }
        public Group(string Name, string Center, Project Project)
        {
            this.Name = Name;
            this.Center = Center;
            this.Project = Project;
        }
        public void input()
        {
            Console.WriteLine("Input Name of the Group:");
            Name = Console.ReadLine();
            Console.WriteLine("Input the Center of this Group:");
            Center = Console.ReadLine();
            Console.WriteLine("Input the Project's Name:");
            Project = Utility.GetProject();
        }
    }
}


#Program.cs


using System;
using System.Collections.Generic;

namespace T2008A
{
    class Program
    {
        public static List<Project> ProjectList = new List<Project>();
        public static List<Group> ListGroup = new List<Group>();

        public delegate void ShowInfor();

        static void Main(string[] args)
        {
            Console.WriteLine("Input a random maximum groups from 2 to 10:");
            int N = Utility.ReadInt();
            while(N < 2 || N > 10)
            {
                Console.WriteLine("Input range must be between 2 and 10");
                N = Utility.ReadInt();
            }
            for (int i = 0; i < N; i++)
            {
                Group g = new Group();
                g.input();
                ListGroup.Add(g);
            }
        }
        
    }
}


#Project.cs


using System;
using System.Collections.Generic;
using System.Text;

namespace T2008A
{
    public 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("Enter Project Name:");
            Name = Console.ReadLine();
            Console.WriteLine("Enter Group by one of the followings\n(Development & Design Website, Website Developer, Application Developer):");
            Group = Utility.ReadGroup();
        }

        public void display()
        {
            Console.WriteLine("Project Name: {0}\n" +
                "Project Group: {1}", Name, Group);
        }
    }
}


#Utility.cs


using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace T2008A
{
    public class Utility
    {
        public static string ReadGroup()
        {
            string str = Console.ReadLine();
            while(!str.Equals("Development & Design Website") &&
                !str.Equals("Website Developer") &&
                !str.Equals("Application Developer"))
            {
                str = Console.ReadLine();
            }
            return str;
        }

        public static Project GetProject()
        {
            string str = Console.ReadLine();
            Project get = new Project();
            foreach(Project p in Program.ProjectList)
            {
                if (p.Name.Equals(str))
                {
                    get = p;
                } else
                {
                    get.input();
                    Program.ProjectList.Add(get);
                }
            }
            return get;
        }

        public static int ReadInt()
        {
            string str = Console.ReadLine();
            bool check()
            {
                try { int.Parse(str); } catch (Exception) { return false; }
                return true;
            }
            while (!check())
            {
                str = Console.ReadLine();
            }
            return int.Parse(str);
        }
    }
}



Hoàng Văn Huy [community,AAHN-C2009G]
Hoàng Văn Huy

2021-10-07 09:06:21


#Program.cs


using System;
using System.Collections.Generic;
using Test2.Models;

namespace Test2
{
    class Program
    {
        public delegate void ShowInfor();

        static void Main(string[] args)
        {

            List<Group> ListGroup = new List<Group>();
            int num = 0;
            do
            {
                Console.WriteLine("Enter number of groups(from 2 to 10): ");
                num = Utility.ReadInt();
                if(num < 2 || num > 10)
                {
                    Console.WriteLine("Number of groups is from 2 to 10. Try again!");
                }
            }
            while (num < 2 || num > 10);
                
            for(int i = 1; i <= num; i++)
            {
                Console.WriteLine("Group number " + i);
                Group newG = new Group();
                newG.Input();
                ListGroup.Add(newG);
            }

            ShowInfor showInfor = delegate
            {
                foreach (Group g in ListGroup)
                {
                    g.Project.Display();
                }
            };

            showInfor();
        }
    }
}


#Group.cs


using System;
using System.Collections.Generic;
using System.Text;

namespace Test2.Models
{
    class Group
    {
        public string Name { get; set; }
        public string Center { get; set; }
        public Project Project { get; set; }

        public Group()
        {
        }

        public void Input()
        {
            Console.WriteLine("Enter Group name: ");
            this.Name = Console.ReadLine();
            Console.WriteLine("Enter center name: ");
            this.Center = Console.ReadLine();
            this.Project = new Project();
            this.Project.Input();
        }

        public void Display()
        {
            Console.WriteLine(this);
        }

        public override string ToString()
        {
            return string.Format("Group name: {0}, Center name: {1}, {2}",this.Name,this.Center,this.Project);
        }
    }
}


#Project.cs


using System;
using System.Collections.Generic;
using System.Text;

namespace Test2.Models
{
    class Project
    {
        public string Name { get; set; }
        private string _group;
        public string Group
        {
            get
            {
                return this._group;
            }
            set
            {
                while (!(value.Equals("Development & Design Website") || value.Equals("Website Developer") ||
                        value.Equals("Application Developer")))
                {
                    Console.WriteLine("Group must be 'Development & Design Website' or 'Website Developer' or 'Application Developer'!");
                    Console.WriteLine("Try again: ");
                    value = Console.ReadLine();
                }
                this._group = value;
            }
        }

        public Project()
        {
        }

        public void Input()
        {
            Console.WriteLine("Enter project name: ");
            this.Name = Console.ReadLine();
            Console.WriteLine("Enter group name: ");
            this.Group = Console.ReadLine();
        }

        public void Display()
        {
            Console.WriteLine(this);
        }
        public override string ToString()
        {
            return string.Format("Project name: {0}, Group name: {1}", Name, Group);
        }
    }
}


#Utility.cs


using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace Test2
{
    class Utility
    {
        public static int ReadInt()
        {
            int value;
            while (true)
            {
                try
                {
                    value = int.Parse(Console.ReadLine());
                    return value;
                }
                catch (Exception e)
                {
                    Console.WriteLine("Try again!!!");
                }
            }
        }
    }
}



Nguyễn Việt Hoàng [community,AAHN-C2009G]
Nguyễn Việt Hoàng

2021-10-07 09:04:25


#Group.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test2
{
    class Group
    {
        public string Name { get; set; }
        public string Center { get; set; }
        public List<Project> ProjectList { get; set; }
        public Group()
        {
            ProjectList = new List<Project>();
        }
        public Group(string name, string center, List<Project> projectlist)
        {
            this.Name = name;
            this.Center = center;
            this.ProjectList = projectlist;
        }
        public void Input()
        {
            Console.WriteLine("Enter Name Group :");
            Name = Console.ReadLine();
            Console.WriteLine("Enter Center Group :");
            Center = Console.ReadLine();
            Console.WriteLine("Enter Sum Of Project :");
            int sum = int.Parse(Console.ReadLine());
            for(int i = 0; i < sum; i++)
            {
                Project p = new Project();
                p.Input();
                ProjectList.Add(p);
            }
        }
        public void Display()
        {
            Console.WriteLine("Name Group :{0}, Center Group :{1}", Name, Center);
            foreach(Project p in ProjectList)
            {
                p.Display();
            }
        }
    }
}


#Program.cs


using System;
using System.Collections.Generic;

namespace Test2
{
    class Program
    {
        public delegate void ShowInfo();
        static event ShowInfo show = null;
        public static List<Group> GroupList = new List<Group>();

        static void ShowMenu()
        {
            Console.WriteLine("1.Enter Sum Of Group");
            Console.WriteLine("2.Display All");
        }
        static void Input()
        {
            Console.WriteLine("Enter Sum Of Group");
            int sum = int.Parse(Console.ReadLine());
            for (int i = 0; i < sum; i++)
            {
                Console.WriteLine("Group[" + (i + 1) + "]");
                Group g = new Group();
                g.Input();
                GroupList.Add(g);
            }
        }
        static void Display()
        {
            ShowInfo show = delegate ()
            {
                foreach (Group g in GroupList)
                {
                    g.Display();
                }
            };
           show();
        }
        static void ListMenu()
        {
            int choose;
            do
            {
                ShowMenu();
                Console.WriteLine("Enter choose value");
                choose = int.Parse(Console.ReadLine());
                switch (choose)
                {
                    case 1:
                        Input();
                        break;
                    case 2:
                        Display();
                        break;
                    case 3:
                        Console.WriteLine("Exits");
                        return;
                    default:
                        Console.WriteLine("Value must be 1 -> 2");
                        break;
                }
            } while (choose != 3);
        }
        static void Main(string[] args)
        {
            ListMenu();
        }
    }
}


#Project.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test2
{
    class Project
    {
        public string Name { get; set; }
        private string group;
        public string Group
        {
            get
            {
                return this.group;
            }
            set
            {
                List<string> valid = new List<string>() { "Development & Design Website", "Website Developer", "Application Developer" };
                while (!valid.Contains(value, StringComparer.OrdinalIgnoreCase))
                {
                    Console.WriteLine("Group cannot empty and must be value :(Development & Design Website,Website Developer, Application Developer) ");
                    Console.WriteLine("Enter Group :");
                    value = Console.ReadLine();
                }
                this.group = value;
            }
        }
        public Project()
        {

        }
        public Project(string name, string group)
        {
            this.Name = name;
            this.Group = group;
        }
        public void Input()
        {
            Console.WriteLine("Enter Name Project :");
            Name = Console.ReadLine();
            Console.WriteLine("Enter Group Project :");
            Group = Console.ReadLine();
        }
        public void Display()
        {
            Console.WriteLine("Name :{0}, Group :{1}", Name, Group);
        }
    }
}



Phan Hữu Tuấn Anh [community,AAHN-C2009G]
Phan Hữu Tuấn Anh

2021-10-07 08:54:34


#Group.cs


using System;
using System.Collections.Generic;
using System.Text;

namespace Techwiz
{
    class Group
    {
        public string Name, Center;
        public Project Project;
        public Group()
        {

        }
        public void Input()
        {
            Console.WriteLine("Moi Ban Nhap Ten:");
            Name = Console.ReadLine();
            Console.WriteLine("Moi Ban Nhap Ten Trung Tam:");
            Center = Console.ReadLine();
            Console.WriteLine("Projet:");
            Project.Input();
        }
        public void Diplay() {
            Console.WriteLine("Name: {0};Center: {1}",Name,Center);
            Console.WriteLine("Project:");
            this.Project.Display();
        }
    }
}


#Program.cs


using System;
using System.Collections.Generic;

namespace Techwiz
{
    class Program
    {
        delegate void ShowInfor();
        static List<Group> groupList;
        static void Main(string[] args)
        {
            groupList = new List<Group>();
            int N;
            do
            {
                Console.WriteLine("Moi Ban Nhap So Luong Group(2-10)");
                N = int.Parse(Console.ReadLine());
            } while (N >= 2 || N <= 10);
            for (int i = 0;i<N;i++) {
                Group group = new Group();
                group.Input();
                groupList.Add(group);

            }
            ShowInfor showInfor = delegate ()
            {
                foreach (Group group in groupList) {
                    group.Diplay();
                }
            };
            showInfor();

        }
    }
}


#Project.cs


using System;
using System.Collections.Generic;
using System.Text;

namespace Techwiz
{
    class Project
    {
        public string Name, Group;
        public Project() { }
        public Project(string name, string group) {
            Name = name;
            if (group.Equals("Development & Design Website")|| group.Equals("Website Developer") || group.Equals("Application Developer")) {
                Group = group;   
            }
        }
        public void Input() {
            Console.WriteLine("Moi Ban Nhap Ten:");
            Name = Console.ReadLine();
            Console.WriteLine("Moi Ban Nhap Group(Group Chi Nhan Development & Design Website, Website Developer, Application Developer):");
            string _group = Console.ReadLine();
            while (!_group.Equals("Development & Design Website") || !_group.Equals("Website Developer") || !_group.Equals("Application Developer")) {
              
                 Group = _group;
            }
        }
        public void Display() {
            Console.WriteLine("Name: {0}; Group: {1}",Name,Group);
        }

    }
}



Le Khanh An [community]
Le Khanh An

2021-10-07 08:48:39



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Program
    {
        public delegate void ShowInfor();
        public static List<Group> groupList = new List<Group>();
        static void Main(string[] args)
        {
            int n;
            do
            {
                Console.Write("Enter n group: ");
                n = int.Parse(Console.ReadLine());
            } while (n < 2 || n > 10);

            for(int i = 0; i < n; i++)
            {
                Group group = new Group();
                group.Input();
                groupList.Add(group);
            }

            ShowInfor showInfo = delegate ()
            {
                foreach(Group group in groupList)
                {
                    Console.WriteLine("project's name: " + group.Project.Name + ", projects' group: " + group.Project.Group);
                }
            };

            showInfo();

            Console.ReadLine();
        }
    }
}



Le Khanh An [community]
Le Khanh An

2021-10-07 08:48:30



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Project
    {
        public string Name { get; set; }
        public string Group { get; set; }

        public Project()
        {

        }

        public void Input()
        {
            Console.Write("Enter project's name: ");
            Name = Console.ReadLine();

            string group;
            do
            {
                Console.Write("Enter project's group(Development & Design Website, Website Developer, Application Developer): ");
                group = Console.ReadLine();
            } while (
                group != "Development & Design Website" &&
                group != "Website Developer" &&
                group != "Application Developer"
            );

            Group = group;
        }
    }
}



Le Khanh An [community]
Le Khanh An

2021-10-07 08:48:18



using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;



namespace test

{

    class Group

    {

        public string Name { get; set; }

        public string Center { get; set; }

        public Project Project { get; set; }



        public Group()

        {

            this.Project = new Project();

        }



        public void Input()

        {

            Console.Write("Enter group's name: ");

            this.Name = Console.ReadLine();



            Console.Write("Enter center: ");

            this.Center = Console.ReadLine();



            this.Project.Input();

        }



        public void Display()

        {

            Console.Write(

                "Group's name: " + this.Name + 

                ", Group's center: " + this.Center + 

                ", Project's name: " + this.Project.Name + 

                ", Project's group: " + this.Project.Group

            );

        }

    }

}




Trần Thị Khánh Huyền [T2008A]
Trần Thị Khánh Huyền

2021-06-04 11:55:31

ly thuyet


Trần Thị Khánh Huyền [T2008A]
Trần Thị Khánh Huyền

2021-06-04 11:54:18


#IMG_20210604_184130.jpg


https://res.cloudinary.com/wegoup/image/upload/v1622807652/vkwkfbfbxrqb6zgik4uc.jpg



bui duy khanh [T2008A]
bui duy khanh

2021-06-04 11:07:14

kết quả bài thi lý thuyết . 





kết quả bài thi thực hành .




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();
        }
    }
}

using System;
using System.Collections.Generic;

namespace TechWiz
{
    
    class Program
    {
        public delegate void showInfor();
        static void Main(string[] args)
        {
            List<showInfor> list = new List<showInfor>();
            List<Group> groupList = new List<Group>();
            Console.WriteLine("So nhom muon nhap:");
            int N = int.Parse(Console.ReadLine());
            for (int i = 1; i <= N; i++)
            {
                Group group = new Group();
                group.Input();
                groupList.Add(group);
                list.Add(group.project.Display);
            }
            foreach (showInfor s in list)
            {
                s();
            }
        }
    }
}



Đăng nhập để làm bài kiểm tra

Chưa có kết quả nào trước đó