L05
Due by the end of Tuesday, 9 February 2021
SUBMIT
/
CHECK
- Download the following files:
-
Examine the code
and run the program
(InheritanceDemo)
to see how it works.
- Programming Activity 1
-
Create a new class,
Lecturer,
that extends Person.
A Lecturer is a Person with a stipend
(a double value representing how much that lecturer will be paid
for teaching a course).
Create a constant for the default stipend
($10,165).
Create two constructors for the class:
one accepts a name and stipend amount;
the other accepts just a name
and uses the default stipend.
Include any appropriate getters/setters.
- Programming Activity 2
-
Give your Lecturer class
a writeOutput method,
which produces output like this:
Name: (name)
Stipend: $(stipend)
- Programming Activity 3
-
Test your Lecturer class by adding the following code to main
in InheritanceDemo:
Lecturer l1 = new Lecturer("Zachary");
Lecturer l1 = new Lecturer("Wilhelmina", 11017.00);
l1.writeOutput();
l2.writeOutput();
pause();
l1.setName("Zack");
l1.setStipend(10800.00);
l1.writeOutput();
pause();
System.out.printf("%s's stipend is $%4.2f.\n", g2.getName(), g2.getStipend());
Note:
You do not need to submit your modified file InheritanceDemo.
I know what it's supposed to look like!
Submit this/these files:
You will be graded on the following:
- Lecturer claims to be a subclass of Person
- ... has the required extra field(s)
- ... does not have any field(s) it shouldn't
- ... has the two-argument constructor
- ... ... that sets the name and stipend correctly
- ... has the one-argument constructor
- ... ... that sets the name and stipend correctly
- ... constructors show correct use of this(...) and super(...)
- ... has all the getters and setters it should
- ... but none it shouldn't
- ... has a writeOutput method that does what it should
- All code conforms to the style guidelines for the course
SUBMIT
/
CHECK