CSE 283 Introduction to Object Oriented Design
Barbara Nostrand, Ph.D.
CSE 283 Labs
Lab 7-8: Projects
1. Practice designing programs that use loops.
Your instructor will assign you one of the following projects, each of which uses loops controlled by conditions.
8.1. Write a program that will read a sequence of numbers from the keyboard, and display the minimum, maximum, average, and range of the entered values. Make the input step "foolproof".
8.2. Extend Calculate.java into a six-function calculator, as follows:
8.3. Write two "graphics" methods:
Use these methods to write a program that draws a picture, such as a flag. For example, you might use these methods to draw a crude facsimile of the U.S. flag that looks like this:
* * * * * * XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX * * * * * * * * * * * XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX * * * * * * * * * * * XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX * * * * * * * * * * * XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX * * * * * * * * * * * XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Try and draw your picture efficiently (i.e., using loops to minimize the number of statements). Feel free to create additional "graphics" methods that simplify drawing your particular flag.
8.4. Write a menu-driven "police sketch artist" program called Artist. The program should use four different menus for:
Each menu must provide at least four different choices. Your program should display "sketches" of the person being described, along the lines of those below (hopefully yours will be better!):
----- | | ....... \|||||||/ --------- . . | | (| O O |) (|-0-0-|) (| . . |) | _\ | | ^ | | > | |\___/| | --- | |||-||| ----- ----- ||||| |||
Organize your program in such a way that it contains no redundant code. For each of the user's choices, write a separate method to process that choice.
Then modify your program to make it dynamic so that the user can experiment with different combinations of facial parts in a single execution. (Hint: Control the program using a loop. ) Start with a 'blank' face. Allow the user to modify this face using a two-level hierarchical menu, with the first level allowing the user to select which facial part they want to modify (i.e., a menu of menus), and the second level allowing the user to select from among the choices for that particular facial part.)
8.5. Use the Fraction class from lab 6 to create a "drill" program that generates random fractions (using class java.util.Random), that younger students can use to practice their fractional arithmetic.
Don't forget to clean up your directory when you are all finished...
Last modified: 2007 OCT 16