Java Reference
In-Depth Information
with 10 roaches. Breed, spray, and print the roach count. Repeat three more
times.
΢΢Exercise P3.12. Implement a VotingMachine class that can be used for
a simple election. Have methods to clear the machine state, to vote for a
Democrat, to vote for a Republican, and to get the tallies for both parties.
Extra credit if your program gives the nod to your favored party if the
votes are tallied after 8 p.m. on the first Tuesday in November, but acts
normally on all other dates. (Hint: Use the GregorianCalendar
classȌsee Programming Project 2.1.)
΢΢G Exercise P3.13. Draw a Ȓbull's eyeȓȌa set of concentric rings in
alternating black and white colors.
Your program should be composed of classes BullsEye ,
BullsEyeComponent , and BullsEyeViewer .
128
129
΢΢G Exercise P3.14. Write a program that draws a picture of a house. It could
be as simple as the accompanying figure, or if you like, make it more
elaborate (3-D, skyscraper, marble columns in the entryway, whatever).
Implement a class House and supply a method draw(Graphics2D
g2) that draws the house.
΢΢G Exercise P3.15. Extend Exercise p3.14 by supplying a House
constructor for specifying the position and size. Then populate your
screen with a few houses of different sizes.
Search WWH ::




Custom Search