InClassExercise09 - CS112 In-class Exercise 9(improved Grab the BlueJ project myclock from public Yuen(CS\cs112BlueJ in the lab When reading the

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CS112: In-class Exercise 9 (improved) Grab the BlueJ project myclock from public \ Yuen(CS) \cs112BlueJ in the lab. When reading the following, pay attention to which class is being discussed. 1. Modify the ClockDisplay class by adding a new method called displayAMPM() which will display the time in 12 hour format. This will necessitate adding new methods to NumberDisplay class. Add a new method displayHour12() to the NumberDisplay class that will display its internal number n as if it is an hour number in 12 hour format. This means a 0 will be displayed as a 12, any number from 1 to 12 is displayed as itself, and any other number will have 12 subtracted from it. Use a temporary local variable, say x . Make an if-elseif- else statement that computes x based on n . Then print x to the Terminal Window analogous to the printing that was done in the regular display() method. Add a new method displayAMorPM() to the NumberDisplay class that will display the letters “AM” or “PM” treating the internal number as an hour in 12 hour format. Namely, if the internal number is from 0 to 11, then “AM” is printed, else “PM” is
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

This lab report was uploaded on 04/08/2008 for the course CSCI 112 taught by Professor Yuen during the Fall '07 term at Lake Forest.

Ask a homework question - tutors are online