Java Reference
In-Depth Information
΢΢΢Exercise P10.7. Reorganize the bank account classes as follows. In the
BankAccount class, introduce an abstract method endOfMonth with
no implementation. Rename the addInterest and deductFees
methods into endOfMonth in the subclasses. Which classes are now
abstract and which are concrete? Write a static method void
test(BankAccount account) that makes five transactions and
then calls endOfMonth . Test it with instances of all concrete account
classes.
493
494
΢΢΢GExercise P10.8. Implement an abstract class Vehicle and concrete
subclasses Car and Truck . A vehicle has a position on the screen.
Write methods draw that draw cars and trucks as follows:
Then write a method randomVehicle that randomly generates
Vehicle references, with an equal probability for constructing cars
and trucks, with random positions. Call it 10 times and draw all of
them.
΢GExercise P10.9. Write a graphical application front end for a bank account
class. Supply text fields and buttons for depositing and withdrawing
money, and for displaying the current balance in a label.
΢GExercise P10.10. Write a graphical application front end for an
Earthquake class. Supply a text field and button for entering the
strength of the earthquake. Display the earthquake description in a label.
΢GExercise P10.11. Write a graphical application front end for a DataSet
class. Supply text fields and buttons for adding floating-point values, and
display the current minimum, maximum, and average in a label.
΢GExercise P10.12. Write an application with three labeled text fields, one
each for the initial amount of a savings account, the annual interest rate,
and the number of years. Add a button ȒCalculateȓ and a read-only text
area to display the result, namely, the balance of the savings account after
the end of each year.
Search WWH ::




Custom Search