In this assignment we will work with the concepts of


In this assignment we will work with the concepts of interfaces and inheritance. We will make use of a extends to create an inheritance hierarchy, and use implements to implement an interface that allows properties to be added to objects at run-time. In addition we will use iterators for looping.

The following requirements will pertain to all your assignments regardless of what your application is supposed to do (i.e. regardless of the design requirements). These requirements are to ensure that your code is readable and maintainable by other programmers (or readable by TA's in our case), and that your program is robust and follows good software engineering practrices You will lose 2 marks from your total assignment mark for each of the following requirements that is not satisfied. If you do not satisfy requirement R0.0 or R0.1 you will get nothing for the assignment.

R0.0) IMPORTANT Uniqueness Requirement. The solution and code you submit MUST be unique. That is, it cannot be a copy of, or be too similar to, someone else's code, or other code found elsewhere. A mark of 0 will be assigned to any assignment that is judged by the instructors or the TA's not to be unique. (You are free to use any code posted on our course web site as part of the course notes or example code.)

R0.1) CODE ORGANIZATION, SUBMISSION AND COMPILATION: Your code should be submitted to culearn as an IntelliJ IDEA project. You can zip up the files is you like but you must use .zip format (not other compression formats.) The markers must be able to compile your code using the Java 1.8 or later compiler from within the course IDE (IntelliJ IDEA in this case). (Demonstration code will be provided as IntelliJ projects and your work will be assessed by opening your code as an IntelliJ IDEA project, compiling the code and then running it. For the purposes of assignments only have one file with a main(){...} routine in it and use the word "main" as part of the class name. The following process will be used to mark your assignment code:

1)The TA will open IntelliJ and open your code as an IntellliJ project. (If you compress your code then provide a .zip file only (we will not support .rar, .tar, ... etc.) Only .zip files.

2)The TA will then rebuild (compile) your project and look for a source file among your code with "main" in its file name and then run that as a java application.

3)Once your code launches it will be evaluated against the assignment requirements.

If any of steps 1,2 or 3 fail the assignment gets a mark of 0. So be aware no partial marks will be awarded to assignments that don't compile and run. Assignments are intentionally broken down into many small requirements. It is better have running code that satisfies some of them than to have code that won't compile and run but claims to be address more requirements.

The following good practice requirements will be in effect for all assignments.

R0.2) All of your variables, methods and classes should have meaningful names that reflect their purpose. Do not follow the convention common in math courses where they say things like: "let x be the number of customers and let y be the number of products...". Instead call your variables numberOfCustomers or numberOfProducts. Your program should not have any variables called "x" unless there is a good reason for them to be called "x". (It's OK to call simple for-loop counters i,j and k etc. when the context is clear and very localized.)

R0.3) All variables in your classes should be private, unless a specific design requirements asks for them to be public (which is unlikely). It is good programming practice to design objects that provide services to others through their public methods. How they store their variables is their own private business.

R0.4) Robustness Requirements: Your program should never crash when is is being run for marking. Make sure you have no null pointer exceptions or attempt to access an array or data structure out of bounds. (We get especially annoyed by out of bounds errors since they still seem to be the number one bug in programming and have been for a long long time!)

R0.5) Code Comment Requirements: Comments in your code must coincide with what the code actually does. It is a very common bug in industry for people to modify code and forget to modify the comments and so you end up with comments that say one thing and code that actually does another. By the way, try not to over-comment your code; instead choose good variable names and method names which make the code more "self commenting".

R0.6) Hard Coded Constants: Your code should not have hard coded constants used in places like if statements or function parameters. Your constants should have meaningful names. Don't have if statements like if(ball.getLocationX() + 40 < 100) ...; instead your code should look like if(ball.getLocationX() + ballRadius < rightBoundaryX) ...; If necssary create local variables that reflect the use of the constant. e.g. double rightBoundaryX = 100; then you can refer to that in your program logic.

Person Class Requirements

R1.1) Create the class Person with the following structure.

public class Person implements Extendable{

public final static String FirstName = "FirstName"; //name of compulsory property
public final static String LastName = "Lastname"; //name of compulsory property

public Person(String aFirstName, String aLastName){...}

public boolean equals(Object anObject){... }

public String toString(){...}

//Interface Extendable methods
//==========================
public void addStringProperty(String aPropertyName, String anInitialValue);
public void removeStringProperty(String aPropertyName);
public void addIntProperty(String aPropertyName, int anInitialValue);
public void removeIntProperty(String aPropertyName);
public void setStringProperty(String aPropertyName, String aStringValue);
public void setIntProperty(String aPropertyName, int anIntValue);
public String getStringProperty(String aPropertyName);
public int getIntProperty(String aPropertyName);
public boolean hasProperty(String aPropertyName);
public boolean hasIntProperty(String aPropertyName);
public boolean hasStringProperty(String aPropertyName);
public void setToStringProperties(String aListOfProperties);
} //end class Person

R1.2) The Person class should have a constructor that takes a first name and last name as String arguments.

R1.3) Person objects should have "FirstName" and "LastName" String properties that are permanent. That is, they cannot be removed. You could implement these as ordinary instance variables or special properties that cannot be removed.

R1.4) The Person class should implement an equals(Object x) method that returns true if x is some kind of person (e.g. Person, Student, TA, etc.) and the objects this and x have the same first name and last name. Otherwise it should return false.

R1.5) The Person class should have a toString() method that, by default, returns the person's first name and last name. If however custom toString properties have been set using the setToStringProperties(String aListOfProperties) method, then the toString() method should return the values of those properties instead.

R1.6) Implement the Extendable protocol methods public void addStringProperty(String aPropertyName, String anInitialValue) and removeStringProperty(String aPropertyName);

R1.7) Implement the Extendable protocol method addIntProperty(String aPropertyName, int anInitialValue) and removeIntProperty(String aPropertyName);

R1.8) Implement Extendable the protocol method public void setStringProperty(String aPropertyName, String aStringValue) and public String getStringProperty(String aPropertyName);

R1.9) Implement Extendable the protocol method setIntProperty(String aPropertyName, int anIntValue) and public int getIntProperty(String aPropertyName);

R1.10) Implement Extendablethe protocol methods
public boolean hasProperty(String aPropertyName);
public boolean hasIntProperty(String aPropertyName);
public boolean hasStringProperty(String aPropertyName);

R1.11) Implement the Extendable protocol method public void setToStringProperties(String aListOfProperties);

R1.12) Implement the Extendable protocol method public void setToStringProperties(String aListOfProperties) so that explanatory words can also be inserted into aListOfProperties. See the decription in the Extendable protocol interface.

R1.13) Implement the Person class so that the main program provided runs and produces the indicated output.

Student Class Requirements

R2.1) Create the class Student with the following structure.

public class Student extends Person{

//Mandatory Student Properties
public final static String StudentNumber = "StudentNumber"; //name of compulsory property

private static int nextStudentNumber = 12345; //initial value of student numbers

public Student(String aFirstName, String aLastName){
super(aFirstName, aLastName);
...
}

public String toString(){ ...}


} //end class Student

R2.2) The Student class should have a constructor that takes a first name and last name as String arguments. It should assign automatically a unique student number integer property using the nextStudentNumber static variable and invoke the superclasses constructor to intialize the person's name. The "StudentNumber" should be a permanent property of students and not be removeable.

R2.3) The Student class should inherit from , that is extend, the Person class.

R2.4) The Student class should have a toString() method that, by default, returns the persons first name and last name and student number. If however custom toString properties have been set using the setToStringProperties(String aListOfProperties) method, then the toString() method should return the values of those properties instead. (Note this means it could probably just rely on the superclass Person's toString() method.)

R2.5) Implement the Student class so that the main program provided runs and produces the indicated output.

TA Requirements
R3.1) Create the class TA with the following structure.

public class TA extends Student{

//Mandatory TA Properties
public final static String OfficeHours = "OfficeHours"; //name of compulsory property

public TA(String aFirstName, String aLastName, String anOfficeHour){
super(aFirstName, aLastName);
...

}

public String toString(){...}

} //end class Person

R3.2) The TA class should have a constructor that takes a first name and last name and the TA's office hours as String arguments. It should invoke the superclasses constructor to intialize the Person and Student properties. The office hours should be a permanent property of TA's and should not be removable.

R3.3) The TA class should inherit from, that is extend the Student class.

R3.4) The TA class should have a toString() method that, by default, returns the persons first name and last name and student number and their office hours. If however custom toString properties have been set using the setToStringProperties(String aListOfProperties) method, then the toString() method should return the values of those properties instead. (Note this means it could probably just rely on superclass Student's toString method.)

R3.5) Implement the TA class so that the main program provided runs and produces the indicated output.

Professor Requirements.

R4.1) Create the class Professor with the following structure.

public class Professor extends Person{

//Mandatory Professor Properties
public final static String Title = "Title"; //name of compulsory property

public Professor(String aFirstName, String aLastName){
super(aFirstName, aLastName);
...

}

public String toString(){...}

} //end class Professor


R4.2) The Professor class should have a constructor that takes a first name and last name as String arguments. It should invoke the super constructor to intialize the Person properties. The professors should also have a permanent "Title" property that is set to the string "Prof.". The Title property should not be removable.

R4.3) The Professor class should inherit from, that is extend the Person class.

R4.4) The Professor class should have a toString() method that by default returns the persons first name and last name but preceeded with the title: "Prof.". If however custom toString properties have been set using the setToStringProperties(String aListOfProperties) method, then the toString() method should return the values of those properties instead. (Note this means it could probably just rely on the superclass Person's toString method.)

R4.5) Implement the Professor class so that the main program provided runs and produces the indicated output.


Classes Team, Tester and PeopleFactory.
Classes Team, Tester and PeopleFactory are provided for you and should be complete. They should not require any modification. If you do want to modify these discuss it with the prof. beforehand.

R5.1 ) When you have completed your program you should be able to run the following main routine in Tester and produce output similiar to the sample output below. Note the class Notice the tester sometimes refers to the people as Person types and sometimes as Extendable types. This is to illustrate that when a class implements an interface, the objects are useable as more than one type.

Attachment:- Assignment.zip

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: In this assignment we will work with the concepts of
Reference No:- TGS01149503

Expected delivery within 24 Hours