This set of labs should help you firm up your knowledge of Java's inheritance mechanism.
Do Programming Exercise P10.2 for (Level 1).
Do Programming Exercise P10.10 for (Level 1).
Do Programming Exercise P10.11 for (Level 3).
Do Programming Exercise P10.12 for (Level 3).
Do Programming Exercise P10.13 for (Level 3). (BTW, what class should that static method test be placed into?)
Do Programming Exercise P10.14 for (Level 3).
I'll add in another (Level 1) to make sure the randomly constructed vehicles don't overlap one another.
Your target level for this lab set is (Level 7). Please, choose from the core choices to meet this goal. After you've met it, you may decide to improve the level total by selecting from the boosters below.
You may do Programming Exercise P10.1 for (Level 1).
You may do Programming Exercise P10.3 for (Level 1.5). Change: Allow the accepted precision to be specified either when constructing the NumericQuestion object or later in its life-cycle (albeit before checkAnswer is called).
You may do Programming Exercise P10.4 for (Level 1.5).
You can add Programming Exercise P10.5 to this for an additional (Level 1).
You may add a method shuffle to the ChoiceQuestion class for (Level 1). (If it isn't clear, this should just rearrange the choices but not affect which is the correct choice — just where it is displayed.)
You may add a method sort to the ChoiceQuestion class for (Level 1). (If it isn't clear, this should just rearrange the choices but not affect which is the correct choice — just where it is displayed.)
You may do Programming Exercise P10.6 for (Level 2). (I'll even throw in another (Level 0.5) if you properly inherit the shuffle and sort methods described above.)
You may do Programming Exercise P10.9 for (Level 1). Also explain how this will affect the MultipleChoiceQuestion class which is designed to subclass the ChoiceQuestion class.
You may do Programming Exercise P10.15 for (Level 2).
As with the vehicles, you can keep the rectangles from overlapping for an additional (Level 1).
You may do Programming Exercise P10.16 for (Level 2).
If you let the user enter a second integer m and draw them an n-by-m grid, I'll throw in an additional (Level 1).
You may do Programming Project P10.2 for (Level 3). (It just seems like a lot of busy work to me. Not really project worthy...*shrug*)
For (Level 3) write a superclass Worker and subclasses HourlyWorker and SalariedWorker. Every worker has a name and a salary rate. Write a method computePay(double hours) that computes the weekly pay for every worker. An hourly worker gets paid the hourly wage for the actual number of hours worked, if hours is at most 40. If the hourly worker worked more than 40 hours, the excess is paid at time and a half. The salaried worker gets paid the hourly wage for 40 hours, no matter what the actual number of hours is. Supply a test program that uses polymorphism to test these classes and methods.
You may combine Programming Exercise P10.12 and the Worker hierarchy above into a single hierarchy for (Level 3). Managers will be salaried workers, of course. Do you really need both Employee and Worker?
You may write a graphical application front end for the BankAccount class from Chapter 3 supplying text fields and buttons for depositing and withdrawing money and for displaying the current balance in a label for (Level 2).
You may write a graphical application front end for the Earthquake class from Chapter 5 supplying a text field and button for entering the strength of the earthquake and displaying the earthquake description in a label for (Level 2).
You may write a graphical application front end for the DataSet class from Chapter 7 supplying text fields and buttons for adding floating-point values and displaying the current minimum, maximum, and average in labels for (Level 2).
You may 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. Also have 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. To save yourself most of the programming trouble, use this chapter's SavingsAccount class. (Notice how you can focus on this one class of the hierarchy to keep the interface from getting overly complicated.) Doing so will get you (Level 2).
You can even change the text area with a bar chart that shows the balance after the end of each year for an additional (Level 2). (Trust me, the bar chart will be complex enough to offset the loss of the text area.)
You may write a program that contains a text field, a button Add Value, and a component that draws a bar chart of the numbers that a user has typed into the text field for (Level 2). Make the simplifying assumption that the first value the user enters will be the largest value.
You can remove the simplifying assumption for an additional (Level 2). This will require you to re-scale the bars every time a newly entered item is larger than your previously largest item.
You may write a program that prompts the user to enter the x and y positions of the center of a circle and its radius. When the user clicks the Draw button, draw the specified circle in a component for (Level 2). Wait a minute! That won't completely do. Add a second button to "Erase" the component and let them start fresh. (Otherwise the drawing may get cluttered after a while.)
You can add a third button to "Undo" the most recent Circle for an additional (Level 1).
You may write a program that allows the user to specify a circle by typing the radius in a text field and then clicking on the center for (Level 2). In this version, you won't need a "Draw" button. But you'll still want to have a button to "Erase" the component and let them start fresh. (Otherwise the drawing may get cluttered after a while.)
You can add a second button to "Undo" the most recent Circle for an additional (Level 1).
You may write a program that allows the user to specify a circle with two mouse presses for (Level 2). The first press identifies the center of the circle and the second a point on the periphery. Hint: In the mouse press handler, you must keep track of whether you already received the center point in a previous mouse press.
You can add a button to "Erase" the component and let them start fresh for an additional (Level 1). (Otherwise the drawing may get cluttered after a while.)
You can add a second button to "Undo" the most recent Circle for an additional (Level 1).
You may write a program that draws a clock face with a time that the user enters in two text fields (one for the hours and one for the minutes) for (Level 3).
Note: Let the user enter their hours in either 12-hour or 24-hour format.
Hint: You need to determine the angles of the hour hand and the minute hand. The angle of the minute hand is easy: The minute hand travels 360 degrees in 60 minutes. The angle of the hour hand is harder; it travels 360 degrees in 12x60 minutes.
This space reserved to add more boosters...