Question 2
Write a Java program to allow user to manage project teams and project members. Each project team has a unique name, and it can include many project members. Each project member has a unique id, name and email (unique).
The details of the classes are given as follows:
class | ProjMember |
Instance variables | id, name and email of a member. You may decide the type of each instance variable. You may include additional variables as you deem fit. |
Constructor | A non default constructor that receives parameters and initialises the instance variables. |
Get and set methods | Include get and set methods for all instance variables. |
Other methods | You may include additional methods as you deem fit. |
toString | Return a descriptive String of the instance. |
class | ProjTeam |
Instance variables | Team name Members of the team. Hint: ArrayList<ProjMember> You may decide the type of each instance variable. You may include additional variables as you deem fit. |
Constructor | A non default constructor that receives one parameter which is the name of the project team. |
Get and set methods | Include get and set methods for all instance variables. |
Other methods | You may include additional methods as you deem fit. |
toString | Return a descriptive String which includes the detail of each project member in the team. |
The program will maintain a list of project team and a list of project members. When the program is started, both lists are empty. The program will allow the user to perform the following operations repeatedly:
1 Add member
2 Remove member
3 Add project team
4 Add member to project team
5 Remove member from project team
6 Print all teams
7 Quit
You may assume that the input values of project name, member id, name and email will be in the correct type and format.
Option 1 Add member
The program will prompt the user to enter id, name and email of a member. The program must check that the id and email do not belong to an existing project member in the member list. If the values are valid, the program will add it as a ProjMember instance into the member list. Otherwise, the program will display an appropriate message.
Option 2 Remove member
The program will prompt the user to enter an id, find the ProjMember instance in the member list that matches the id, and remove the instance from the list If there is no matching instance, the program will display an appropriate message. If an instance is found, the program must check if the instance is assigned to any project team. If it is assigned, the program will not remove the instance but will display an appropriate message.
Option 3 Add project team
The program will prompt the user to enter the name of a project team. The program must check that the name does not belong to an existing project team in the project list. If the name is valid, the program will add it as a new instance in the project list. Otherwise, the program will display an appropriate message.
Option 4 Add member to project team
The program will prompt the user to enter a project team name and a member id. The program will check if there is a matching project team (in the project list) and project member (in the member list). If there is no matching project team or member, the program will display an appropriate message. Otherwise, the program will add the member to the project team.