1 / 10

Lab#3

Lab#3. T ranslating uml d iagrams. Q1: Write code for the following classes plus its main where:. Department. name: name of a department in a university. numEmployees : number of employees in the department. University. name : the university name.

miller
Télécharger la présentation

Lab#3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lab#3 Translatinguml diagrams

  2. Q1: Write code for the following classes plus its main where:

  3. Department • name: name of a department in a university. • numEmployees: number of employees in the department.

  4. University • name: the university name. • numPublications: number of publications of the university. • numDepts: the number of departments in the university. • depts: an array of departments of the university. • addDept (in dept: Department): boolean adds the given department in the first empty location in the array depts. • toString () :String returns a string containing the information of the university and all its departments.

  5. MOHE (Ministry of High Education) • univs: an array of universities. • univsCnt: the number of universities currently enrolled in the MOHE. • isEmpty (): boolean returns true if the univs array is empty. • isFull (): boolean returns true if the univs array is full. • getUniv (in ndx: int): University returns the University object that has the specified index in the array univs. • search (in name: string): int returns the index in the array univs of the University having the specified name. • sumPubs(): int returns the summation of the number of publications of all universities.

  6. MOHE (Ministry of High Education) • removeUniv(in name: string): boolean if the array univs is not empty, deletes the university having the specified name, such that all other universities remain in the same order in the array. • addUniv (in univ: University): boolean if the array univs is not full, adds the given university to the array, such that the new university is added in its correct location in the array, according to the alphabetical order of university names. • univsHavingDept (in dept: string): University []  returns an array containing all universities that have a department with the given name (hint: use the copy constructor of the class University to create a new object and add it to the array that will be returned).

  7. Main() • Create a MOHE object which can hold a maximum of 20 universities. Then display the following menu: • Add a new University to the MOHE: • Ask the user to enter the university information. • Ask the user about the number of departments in the university and add the information of the departments. • Delete a university from the MOHE, knowing its name. • Display the information of all universities in the MOHE. • Display the information of a certain university, knowing its location in the array. • Search for certain university by name and display its location in the array. • Find the sum of the publications of all universities in the MOHE. • Display the names of all universities in the MOHE which have a “Computer Science” department. • Exit the program.

  8. Evaluation • Write a Java class named University that includes the following data members: • name: the university name . • The class also includes the following methods: • Aconstructor with one parameter that receives the university’s name. • Set and get methods if needed.

  9. Evaluation • Write a Java class named MOHE that includes the following data members: • univs: an array of university , that contains the universities enrolled in the MOHE. • The class also includes the following methods: • Aconstructor with one parameter that receives an array of universities enrolled in MOHE. • removeUniv(in name: string): boolean if the array univs is not empty, deletes the university having the specified name, such that all other universities remain in the same order in the arraywith no empty records between them. • toString (): String  Returns a string that consists of the names of all the enrolled universities in the MOHE (in the same order as the array).

  10. Evaluation Write another Java class called TestMOHEwith a main method that will test the class MOHE. The main method should do the following: • Create a MOHE object that contains the following universities • Imam University • KSU • PNU • PSU • Print the universities enrolled in MOHE using the toString() method. • Delete ‘PNU’ • Print the universities enrolled in MOHE using the toString()method.

More Related