CSE 283 Introduction to Object Oriented Design

Barbara Nostrand, Ph.D.


CSE 283 Labs
Welcome to the site for CSE 283 Labs!

 

Lab 5: Projects

Prev | Next | Lab 5

 

Objectives

1. Practice designing a solution to a problem;
2. Practice using Java selective and repetitive behavior;
3. Practice writing methods; and
4. Practice writing reusable code.

Introduction

Your instructor will assign you one of the following problems. To solve your problem, write a program that inputs the necessary information to compute and output the indicated values, as efficiently as possible. Use object-centered design, following the example in the lab exercise, and then employ stepwise translation to encode your algorithm in Java. Use methods and separate module classes where appropriate to make your code reusable. Then test your program thoroughly, using the facilities at your disposal.

Projects

5.1. Write a program called Grader that asks the user how many test scores they have, and then reads that many test scores, averages them, and displays the average and a pass/fail grade appropriate for that average (passing is 60 or higher, failing is below 60). Use a module method to average the input values.

5.2. Write a "password protection" method that you can use to guard your programs. When called, this method should ask the user for a password. It should allow the user N tries at entering the correct password, where N is a value received from its caller.. If the user enters the correct password, the method returns control to its caller, where execution proceeds as normal. If the user fails to enter the correct password after N tries, then the method should use System.exit(1) to terminate the program. Store your method in a separate module class, so that different programs can share it.

5.3. Proceed as in 5.1, but instead of displaying a pass/fail grade, the program should compute a "normal" letter grade (90-100 = A, 80-89 = B, 70-79 = C, 60-69 = D, ...).

5.4. Write two methods:

  • sum(n) that computes the value (1 + 2 + ... + (n-1) + n)
  • factorial(n) that computes (1 * 2 * ... * (n-1) * n)

Your methods should check the value of n is positive; if not, they should display an informative error message and return 0.

Store them in a separately compiled module. Write a driver program that lets the user apply either of these methods to an input value, displaying the result.

Design Document

Begining with this project,  you should include a design document in your project directory.  Ideally,  your design document should be in PDF format.  However,  LaTeX and Nisus documents will also be accepted for this assignment. 

You have already seen several examples of project designs.  For example,  the Software Engineering segment for this week contains the essential elements of a design document.  Specifically,  it contains the following elements: 

  • Behavior Description - This should include a basic user manual. 
  • Object Catalogue - This includes both those classes which you define and those which you explicity use. 
  • Method Catalogue - This should include predefined methods and those which will be written for your project. 
  • Attribute Catalogue - This should identify the attribute variables and constants associated with each of the classes you will be defining. 
  • Algorithm Designs -- These are English language descriptions of the algorithm(s) employed by each of the new critical methods in your system.  You should copy these algorithm descriptions as comments into your code as part of your development process. 
  • Class Hierarchy Diagrams -- These diagrams graphically illustrate the inheritance relationships between the classes in your system. 
  • Data Structure Diagrams -- These diagrams graphically illustrate the composition of macroscopic data entities in your system.  These diagrams will not be covered in this course as they are part of the subject matter of the Data Structures course. 
  • User Interface Graphical Layout Diagrams -- These are used to graphically design the appearance of the user interface and to specify the location,  appearance,  and behavior of objects placed on the screen.  Layout Diagrams are older than current GUI systems. 

Don't forget to clean up when you are all finished...

Prev | Next | Lab 5

 
  Home

Schedule

Help

Lab 0

Lab 1

Lab 2

Lab 3

Lab 4

Lab 5

Lab 6

Lab 7-8

Lab 9

Lab 10

Lab 11

Lab 12

Lab 13






Last modified: 2007 OCT 28
bnostran@syr.edu