Preparation
Do the following before arriving at lab:
- Read chapter 3.1 - 3.10
- Bring your textbook to lab
Objectives
After completing this lab, you should be able to:
- invoke internal and external methods
- write if statements to solve a problem
Exercises
Read Chapter 3 and perform each of the following exercises. Write your
responses to any questions on this paper.
- Open the Clock-Display project in Chapter 3
- Add your name as author
- Modify the updateDisplay ( ) method to display the time as a 12 hour
clock using am and pm. DO NOT change the values of any of the fields.
00:15 becomes 12:15 am
08:20 becomes 8:20 am
12:30 becomes 12:30 pm
16:40 becomes 4:40 pm
- When finished, show your instructor.
- Print the modified source code
(with your name).
You will now work on a separate project involving Dice.
- Connect to the R: drive in the CSIS folder.
- Open the Dice-Games project using BlueJ
- Save the project to your N: drive (pay attention to where you save it).
- Create a new class called Triplets
- Define three instance variables of type Dice.
- Implement the following methods:
- public Triplets ( ) - instantiate the dice in this constructor.
- public void play ( ) - roll all dice. If all three dice values match,
print "Three of a kind". If only two values match, print "Two of a
kind". If all three values are different, print "Three singles". The
goal is to keep this method as short as possible with elegant but readable
code.
- When finished, show your instructor the working code.
- Print the source code (with your name).
Sample Output
2 4 1: three singles
3 5 5: two of a kind
4 4 4: three of a kind
Grading Criteria
This lab is worth a possible 10 points.
- Clock Display source code (5 pts)
- Triplets source code (5 pts)
|