Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A3. The following class diagram shows that an herbal company has a number of sales teams which is supervised by a manager, and in each
A3. The following class diagram shows that an herbal company has a number of sales teams which is supervised by a manager, and in each team there are a number of salespersons in it: supervises has Manager -name : String +Manager(String name) +getName(): String 1 Marketing Team -name : String +Marketing Team(String name) +getName(): String 1 1..* Salesperson -SalesID : String +Salesperson(String SalesID) +getID(): String Specialty SP -cert: String +Specialty SP(String salesid, String Cert) +getCert(): String (a) A specialty salesperson (SpecialtySP) is a salesperson with a professional certificate. With reference to Test.java on next page, implement the classes Marketing Team, Salesperson and SpecialtySP based on the given class diagram. You may assume that the class Manager has been implemented for you. Note: Apart from the attributes and methods specified in the class diagram, it may be necessary to add attributes and methods to classes Manager, Marketing Team and Salesperson for implementing the one-to-one association and the one-to-many association. [13 marks] (b) Assume that you have successfully implemented all the classes in the given class diagram, give the expected output when the test program Test.java runs. [2 marks] Test.java: import java.util.*; public class Test { public static void main(String[] args) { Manager () m = new Manager[2]; m[0] = new Manager ("Peter Wong"); m[1] = new Manager ("Ken Choi"); Marketing Team ( ) t = new MarketingTeam[2]; t[0] = new MarketingTeam ("Japan Products"); t[1] = new MarketingTeam (European Products"); m[0].setTeam(t[1]); t[1].setManager (m[0]); m[1].setTeam ( [0]); t[0].setManager (m[1]); // setTeam method in class Manager is to set the MarketingTeam of the Manager 11 setManager method in class Course is to set the Manager of the Marketing Team // Please refer to the "Note" of Question A3 (a). Salesperson I s = new Salesperson[4]; s[0] = new Salesperson ("S0001"); s[1] = new SpecialtySP ("S0002", "Herbal Product"); s [2] = new Specialtys ("S0003", "Dietary Prodcut"); s [3] = new Salesperson ("S0004"); t[0].adds (s[0]); s[0].setTeam (t[0]); troj.addSP (s[2]); [2].setTeam (t[0]); t[1].addSP (s[1]); s[1].setTeam (t[1]); t[1].addSP (s[3]); [3].set Team (t[1]); // addsP method in class Marketing Team is to add salesperson to the marketing team. // setTeam method in class Salesperson is to set the marketing team of the salesperson. // Please refer to the "Note" of Question A3 (a). Enumeration salespersonList= m[0].getTeam().getAllSP(); // getTeam method in class Manager is to return the marketing team of the Manager // getAllse method in class Marketing Team is to find and return all salespersons of a team 11 Please refer to the "Note" of Question A3 (a). System.out.print("The list of specialty salesperson supervised by "); System.out.println(t[0].getName()); while (salespersonList.hasMoreElements()) { Salesperson sp = (Salesperson) (salespersonlist.nextElement()); if (salesperson instanceof SpecialtySP) System.out.print (salesperson.getID() + ", Certificate: "); System.out.println(((SpecialtySP) salesperson).getCert())
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started