Joined: Tue Oct 27, 2009 1:40 am Posts: 1 Has thanked: 0 time Have thanks: 0 time
Person class that contain the following info. and inherit the Attributes Name Java Type m_Age (stores the age) public Int m_Name (stores the name) public String Method Name Accessor Type Person Constructor that takes a String for the name. This single parameter should be assigned to m_Name. m_Age initially should be set to zero. Default ToString method that returns String. This method must concatenates the name and age together in a descriptive way and returns the result. protected Access methods to get/set each data member Default a) PersonAbstract class that has one abstract method: ToString b) Create Teacher Class that inherits the Person Class andextend that to the following: • A single Private Boolean data member named m_Tenure. m_Tenure indicates if the teacher has tenure or not. • Access methods (get/set) for m_Tenure. • A Constructor that simply takes the name of the teacher as a parameter. In this constructor, i. Pass this name up to the base class constructor. ii. Initialize m_Tenure to false. • A ToString method as described in Person Class. The ToString method in Teacher should first call up to the ToString method in Person in to order to retrieve the Person part of the string. It should then return a string output saying whether the teacher has tenure or not,
according to m_Tenure.
Student and add the following: • A single int data member named m_StudentNumber. m_StudentNumber will store the student’s student number. • A Constructor that simply takes the name of the student as a parameter. In this constructor, i. Pass this name up to the base class constructor. ii. Initialize m_StudentNumber to 0. • Access methods for m_StudentNumber. • Add a toString method, check whether m_StudentNumber is zero or not, then return a string with the student number if it is • on, Teacher and Student. Print out the object reference name that you have just constructed . • Create two new instances of Teacher Initialize both teachers to the same name. • Compare the two teachers with the equals method. Print out if the teachers are the same or different. with the name Teacher 1 and Teacher 2. Create an instance of Pers With empty constructor. not zero. • Create 10 instances of Student with Student Number from And use a loop to display a list. 1 Student1 1 to 10 and name the Students as Student1 to Student10. 2 Student2 3 Student3 10 Student10 • • • e.g. Note: Comments and Indentation (3 ) Identify where in your code that use has- a and is- a relationship (2) c) Create another class d) Create a PersonTest Class and do the following:
msi_333
Question subject: Re: Attributes Name Java Type
Posted: Tue Oct 27, 2009 11:53 am
Joined: Tue Mar 27, 2007 10:55 pm Posts: 2279 Location: Earth Has thanked: 39 time Have thanks: 61 time
hey , this is an assignment , you have to try by yourself , and if you have a specific problem , post it .
_________________ Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )