Homework 3: Inheritance
- Review the inheritance example files in the
account/
and
shape/
directories.
- Create a directory named javahw3/ in your directory.
- Create the following classes:
- Create an abstract class
Member
with attributes
name
, gender
and birthYear
and method
age()
.
- Create a class
Student
which extends Member
with attributes degree
and admissionYear
.
- Create a class
Staff
which extends Member
:
with attributes payRate
and hoursWorked
, boolean
attribute hourly
.
- Add a method
pay()
which returns either payRate
or payRate
* hoursWorked
.
- Create a
Faculty
class which extends Staff
with attribute faculty
.
- For each class,
- All attributes should be
private
and have public
accessor methods.
- Each class should have a constructor which takes the attributes as
parameters.
- Each class should have a
toString()
method which returns a
string with all the attributes.
- In a file named
MemberTest.java
, create a class named with just one method named main()
.
- Prompt the user to input all the attributes of at least one student, one
staff member and one faculty member.
- Display these objects using
System.out.println()
.
- Compile the programs by typing
javac *.java
.
- Run, test, debug and document the programs.
- Use Ark to create an archive of your directory named
javahw3.zip
.
- Send the source code to the
instructor as an attachment in a message with subject java hw 3.