CSE logo University of Washington Department of Computer Science & Engineering
 CSE 142 Winter 2003 -- Homework #2
  UW Home     CSE Home   Message Board    Contact Info 

CSE 142
 Home page
 Syllabus
Classwork
 Calendar
 Homework
 Projects
 Exams
 Quizzes
Software & Computing
 Programming Lab Info
 Computing at Home
 Java Libraries
 Troubleshooting
Staying in Touch
 Discussion Board
 Virtual TA
 Announcement Archive
 Mailing Lists
Staff
 Instructors
 TAs
 Consultants
 Consultant Schedule
Check Your Scores
 MyUW
   

CSE 142 Homework #2

Due: Wednesday, January 22 at 9:00 PM. No late assignments will be accepted.

Directions: Please answer the following questions. Use full sentences when answering questions that require explanations. Remember to acknowledge any help you receive from individuals outside the course staff. These questions are based on material from lecture and from Chapter 2 thru Chapter 5 in the textbook.

You answers should be formated using Microsoft Word or WordPad (.doc file), Notepad or any plain text editor (.txt), or any other file format that can be read by recent versions of Microsoft Word. When you are done, use this turnin form to submit your assignment over the web. If you make a mistake, you can resubmit your assignment as often as needed. We will grade the last one that you hand in. Your graded assignment will be returned to you via email. Please include the questions along with your answers in your homework file.

Remember to get started right away. Don't wait until Wednesday after dinner to begin, or you are likely not to finish on time.

Grading Guidelines: Unless indicated otherwise, each question or part of a question is worth 2 points. To gain the full 2 points, your answer must have no significant flaws, must be clear to the reader, and must be complete (but remember that complete does not mean verbose - be concise and to the point). One point will be awarded to answers that are partially correct, are somewhat unclear, or are incomplete. You must show credible effort to gain at least one point per question.

1. Suppose you want to model a system to manage a university library's holdings. Give two examples of classes you would design for this system. In your class description, include at least five properties for these classes. You do not need to draw the boxes. An underscored class name followed by a list of properties is fine.

2. [based on Chapter 3] For question 1, you designed the properties of two classes. Suggest reasonable identifiers for each of these properties. Give examples of inappropriate identifiers for each property and state why the identifiers are inappropriate.

3. [Adapted from Exercise 2.9] Could an object representing a student in a registration system be used to model a user of a university library system? Are all properties of a student relevant for a library user? If not, which properties wouldn't you model for students in a library system? Are new properties needed for a library user? If so, name these new properties.

4. [4 Points] Design classes to model interactions with a library system. First, design the class for Library User, specifying the properties of the class. You may want to design other classes in order to have properties reference other objects. Think about what books or journals you have checked out at the moment, their due dates, and the properties you used to model a Library User. To keep things simple, assume a library user can have at most 5 items checked out at any one time. Draw object diagrams [See page 41 in the text to see examples of object diagrams] to represent yourself as a library user, what you have checked out, and when your items are due. Remember, properties of objects can reference other objects. Do your best to create diagrams. The Paint program that comes as an accessory with Windows allows you to draw simple diagrams. You can create a file of the diagram and paste this diagram into your homework file. If you currently have no books or journals checked out of the library, assume you have the following items for this question:

Item 1 due May 13, 2003:
Joseph Psotka, L. Dan Massey, Sharon A. Mutter. Intelligent Tutoring Systems: Lessons Learned. Hillsdale, NJ: Lawrence Erlbaum Associates Publishers, 1988. ISBN 0-8058-0023-9

Item 2 due January 31, 2003:
Wilbert J. McKeachie. McKeachie's Teaching Tips. Boston: Houghton Mifflin Company, 2002. ISBN 0-618-11649-4

Item 3 due March 11, 2003:
Jane Margolis and Allan Fisher. Unlocking the Clubhouse: Women in Computing. Cambridge, MA: The MIT Press, 2002. ISBN 0-262-13398-9

5. [Exercise 4.3] Write Java specifications for commands that will change an Explorer's strength and stamina. You can find the specification for the class Explorer on page 81.

6. [3 points] Suppose you are designing an online ticket agent that sells tickets for concerts. A class, called TicketTracker defines objects that keep track of how many tickets have been purchased, how many tickets are left, and how much money has been spent on tickets. Each object (instance) of class TicketTracker represents information about the tickets sold for a particular concert. The TicketTracker class has the following properties and responsibilities:

properties
total tickets available [concert hall capacity]
total tickets currently available
total tickets sold thus far
total amount of money earned thus far

responsibilities
purchase ticket [with number of tickets and total price for the purchased tickets as information passed to this responsibility]
refund ticket [with number of tickets and total price for the refunded tickets as information passed to this responsibility]
set number of tickets available
set number of tickets currently available
set tickets sold thus far
set total amount of money earned so far
get total tickets available
get total tickets currently available
get total tickets sold thus far
get total amount of money earned so far

Write the Java specifications for the class TicketTracker. Remember: the specifications include the constructors, the queries, and the commands, but not the private implementation details of the class.

7. [3 points] Implement the TicketTracker class by adding implementation details to the class specification from question 6. Use the upper window in DrJava to enter the code for the class. You can test your code by creating objects (instances) of the class in the lower interactions window. Use appropriate comments help the reader understand your code. Turn in your code by pasting it into your homework file.

8. Provide evidence that your TicketTracker class works properly. Give examples of code you used to test your class, followed by explanations of what happens when the code is executed. Provide evidence that the state of the object is what you expect. Also provide evidence that you tested multiple instances of the class TicketTracker.


CSE logo Department of Computer Science & Engineering
University of Washington
Box 352350
Seattle, WA  98195-2350
[comments to cse142-webmaster]