Question

Question 3. (10 marks) Here are three incomplete Java classes that model students, staff, and faculty members at a university

private boolean hasTenure; private String rank; // Assistant, Associate, Full Professor private IDNumber employeeNumber // Co

API for Selected Java Classes Class Datee .Date ) - Constructs a Date object corresponding to now; that is, the instant at wh

public boolean after (Date when) Tests if this date is after the specified date. Returns true if and only if the instant in t

public boolean after (Date when) Tests if this date is after the specified date. Returns true if and only if the instant in t

Class ArrayList Size Determination . public int size - Returns the number of elements in this list. . public boolean isEmpty)

The following is for java programming. the classes money date and array list are so I are are pre made to help with the coding so you can resuse them where applicable

Question 3. (10 marks) Here are three incomplete Java classes that model students, staff, and faculty members at a university class Student [ private String lastName; private String firstName; private Address address; private String degreeProgram; private IDNumber studentNumber; // Constructors and methods omitted. class Staff private String lastName; private String firstName; private Address address; private String department; private Date hireDate; private Money annualSalary; private int level / Level 1, 2, 3, .. ., 10 private IDNumber employeeNumber; // Constructors and methods omitted class Faculty ( private String lastName; private String firstName; private Address addressi private String department; privat private Money annualSalary; e Date hireDate;
private boolean hasTenure; private String rank; // Assistant, Associate, Full Professor private IDNumber employeeNumber // Constructors and methods omitted. These three classes are an example of poor object-oriented design. There is no attempt to exploit class reuse through inheritance (generalization) The UML diagram shown below presents a better object-oriented design. It identifies additional classes in the problem domain, and models the inheritance relationships between these classes. Person Employee Student Faculty Staff Write Java classes for the five classes that are depicted in the UML diagram, showing how the inheritance relationships would be implemented. You do not have to redraw the UML diagram; instead all you have to do is translate the diagram into Java classes. Allocate each field (from the three classes provided at the beginning of the question) to the most appropriate class. You should attempt to minimize the number of duplicated instance variable declarations, while ensuring the revised Student, Staff, and Faculty classes provide as complete a model of the three types of people as the original three classes. Your class definitions must ensure that it is not possible to create instances of class Person and class Employee. Do not define any constructors or methods in your classes.
API for Selected Java Classes Class Datee .Date ) - Constructs a Date object corresponding to now; that is, the instant at which the Date object was created, measured to the nearest millisecond Date (long millis) Constructs a Date object that represents the specified number of milliseconds since January 1, 1970, 00:00:00 GMT . public long getTime) -Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object. public void setTime (long time) Sets this Date object to represent a point in time that is time milliseconds after January 1, 1970 00:00:00 GMT . public boolean before (Date when) Tests if this date is before the specified date. Returns true if and only if the instant in time represented by this Date object is strictly earlier than the instant represented by when; false otherwise.
public boolean after (Date when) Tests if this date is after the specified date. Returns true if and only if the instant in time represented by this Date object is strictly later than the instant represented by when; false otherwise. public boolean equals (Object obj) Compares this object against the specified object. The result is true if and only if the argument is not null and is a Date object that represents the same date as this object. public String tostring ) Returns a String representation of this Money object in the form: "$ddd. cc" or "-Sddd.cc", where ddd is the dollars part and cc is the cents part.
public boolean after (Date when) Tests if this date is after the specified date. Returns true if and only if the instant in time represented by this Date object is strictly later than the instant represented by when; false otherwise. public boolean equals (Object obj) Compares this object against the specified object. The result is true if and only if the argument is not null and is a Date object that represents the same date as this object. public String tostring ) Returns a String representation of this Money object in the form: "$ddd. cc" or "-Sddd.cc", where ddd is the dollars part and cc is the cents part.
Class ArrayList Size Determination . public int size - Returns the number of elements in this list. . public boolean isEmpty) - Returns true if this list is empty Element Access . public Object get (int index) - Returns the element stored at the specified position (index) in this list. Insertion and Modification . public boolean add (Object o) Appends the specified element to the end of this list. This . public void add (int index, Object element) -Inserts the specified element at the . public Object set(int index, Object element) -Replaces the element at the specified method always returns true specified position (index) in this list. position (index) in this list with the specified element. It returns the element previously stored at that position. Removal .public Object remove (int index) Removes the element at the specified position (index) in this list, and returns the element that was removed from the list. . public boolean remove (Object o) Removes the first occurrence of the specified element in this list. It returns true if the list contained the specified element; otherwise it returns false and leaves the list unchanged. . public void clear ( -Removes all elements from this list. Searching . public boolean contains (Object o) - Returns true if this list contains the specified element. . public int indexof (Object o)Returns the index of the first occurrence of the specified element in this list, or -1 if the list does not contain the element. . public int lastIndexof (Object o) Returns the index of the last occurrence of the specified element in this list, or -1 if the list does not contain the element. Miscellaneous . public Iterator iterator )Returns an iterator for the elements in this list. . public String toString) -Returns a string representation of this list. Class Iterator . public object next- Returns an object that has not yet been returned by this iterator. Must only be invoked when hasNext () returns true . public boolean hasNext) - Returns true if this iterator's collection contains at least one object that has not yet been returned by next ); otherwise returns false
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Below would be the OOPs design of the classes

abstract class Person{
  
private String lastName;
private String firstName;
private Address address;
  
  
}

abstract class Employee extends Person{
private String department;
private Date hireDate;
private Money annualSalary;
private IDNumber employeeNumber;
  
}

class Student extends Person{
private String degreeProgram;
private IDNumber studentNumber;
}
class Faculty extends Employee{
private boolean hasTenure;
private String rank;
}
class Staff extends Employee{
private int level;   
}

Abstract classes wont allow instance creation. To access the private members of abstract classes in subclasses we need getters and setters which  I have knowingly left.

Add a comment
Know the answer?
Add Answer to:
The following is for java programming. the classes money date and array list are so I are are pre...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • JAVA - Circular Doubly Linked List Does anybody could help me with this method below(previous)? public...

    JAVA - Circular Doubly Linked List Does anybody could help me with this method below(previous)? public E previous() { // Returns the previous Element return null; } Explanation: We have this class with these two implemented inferfaces: The interfaces are: package edu.ics211.h04; /** * Interface for a List211. * * @author Cam Moore * @param the generic type of the Lists. */ public interface IList211 { /** * Gets the item at the given index. * @param index the index....

  • Please use Java programming: Modify both ArrayList and LinkedList classes and add the following method to...

    Please use Java programming: Modify both ArrayList and LinkedList classes and add the following method to both classes: public void reverseThisList(), This method will reverse the lists. When testing the method: print out the original list, call the new method, then print out the list again ------------------------------------------------------------------------- //ARRAY LIST class: public class ArrayList<E> implements List<E> { /** Array of elements in this List. */ private E[] data; /** Number of elements currently in this List. */ private int size; /**...

  • When compiling the LinkedList and Iterator class, the following error is being produced: Note: LinkedList.java uses...

    When compiling the LinkedList and Iterator class, the following error is being produced: Note: LinkedList.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Any suggestions? public class LinkedList<T> {    Node<T> itsFirstNode;    Node<T> itsLastNode;    private int size;    public LinkedList() {        itsFirstNode = null;        itsLastNode = null;          size = 0;    }    public Iterator<T> getIterator() {        return new Iterator(this);    }    // THIS WILL NEED...

  • Create a linked list with given code Given code: import java.util.Iterator; public interface Set { /**...

    Create a linked list with given code Given code: import java.util.Iterator; public interface Set { /** Removes all of the elements from this set */ void clear(); /** Returns true if this set contains no elements @return true if this set contains no elements */ boolean isEmpty(); /** Returns the number of elements in this set (its cardinality) @return the number of elements in this set */ int size(); /** Returns an iterator over the elements in this set @return...

  • JAVA: Already completed: MyList.java, MyAbstractList.java, MyArrayList.java, MyLinkedLink.java, MyStack.java, MyQueue.java. Need to complete: ReversePoem.java. This program has...

    JAVA: Already completed: MyList.java, MyAbstractList.java, MyArrayList.java, MyLinkedLink.java, MyStack.java, MyQueue.java. Need to complete: ReversePoem.java. This program has you display a pessimistic poem from a list of phrases. Next, this program has you reverse the phrases to find another more optimistic poem. Use the following algorithm. 1.   You are given a list of phrases each ending with a pound sign: ‘#’. 2.   Create a single String object from this list. 3.   Then, split the String of phrases into an array of phrases...

  • Please answer the following question with Java Modify the Employee and ProductionWorker classes provided below so...

    Please answer the following question with Java Modify the Employee and ProductionWorker classes provided below so they throw exceptions when the following errors occur. - The Employee class should throw an exception named InvalidEmployeeNumber when it receives an employee number that is less than 0 or greater than 9999. - The ProductionWorker class should throw an exception named InvalidShift when it receives an invalid shift. - The ProductionWorker class should thrown anexception named InvalidPayRate when it receives a negative number...

  • How to create a constructor that uses parameters from different classes? I have to create a...

    How to create a constructor that uses parameters from different classes? I have to create a constructor for the PrefferedCustomer class that takes parameters(name, address,phone number, customer id, mailing list status, purchase amount) but these parameters are in superclasses Person and Customer. I have to create an object like the example below....... PreferredCustomer preferredcustomer1 = new PreferredCustomer("John Adams", "Los Angeles, CA", "3235331234", 933, true, 400); System.out.println(preferredcustomer1.toString() + "\n"); public class Person { private String name; private String address; private long...

  • I was told I need three seperate files for these classes is there anyway to tie...

    I was told I need three seperate files for these classes is there anyway to tie all these programs together into one program after doing that. I'm using netbeans btw. import java.util.ArrayList; import java.util.Scanner; /** * * */ public class MySorts {       public static void main(String[] args) {             Scanner input = new Scanner(System.in);             String sentence;             String again;             do {                   System.out                               .println("Enter a sentence, I will tell you if it is a palindrome: ");...

  • Java help: Please help complete the locate method that is in bold.. public class LinkedDoubleEndedList implements...

    Java help: Please help complete the locate method that is in bold.. public class LinkedDoubleEndedList implements DoubleEndedList { private Node front; // first node in list private Node rear; // last node in list private int size; // number of elements in list ////////////////////////////////////////////////// // YOU MUST IMPLEMENT THE LOCATE METHOD BELOW // ////////////////////////////////////////////////// /** * Returns the position of the node containing the given value, where * the front node is at position zero and the rear node is...

  • Use Java and creat proper classes to finish this problem Write a class called Date that...

    Use Java and creat proper classes to finish this problem Write a class called Date that represents a date consisting of a year, month, and day. A Date object should have the following methods: public Date(int year, int month, int day) Constructs a new Date object to represent the given date. public void addDays(int days) Moves this Date object forward in time by the given number of days. public void addWeeks(int weeks) Moves this Date object forward in time by...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT