Homewrk0
CS 219 - HOMEWORK 0
(Due: Mon, 8/24/2015. Total: 20 pts)
HOMEWORK SUBMISSION POLICIES:
· Put all of your work, even project source code and screenshots of project output, into a single homework document, and submit that document to this assignment on Canvas by midnight of the day that the homework is due. Put your name at the top of that document.
· Make sure that the problems in your homework document are in the same order as the problems in the homework assignment.
· In your homework document, make sure that you use monospace font for your project source code and project output. The monospace font ensures that text that's supposed to be aligned stays aligned when it's printed. If your printed source code is not aligned properly, you will lose style points. To achieve monospace font, highlight the relevant text, right click, and select Font. In the Font window, search for Courier New, select it, and click OK to apply your font selection.
MANDATORY UNGRADED WORK:
· Complete my Get Started with Eclipse in the Computer Lab tutorial (listed on Canvas ( Modules ( Week1 overview).
· Review Java Coding Conventions Guidelines document (listed on http://www.park.edu/ics under Software Resources: Tutorials and Guidelines). You must follow the guidelines found in this document.
Submit answers for all of the following questions.
EXERCISES (2 pts, ½ pts each):
The first two exercise questions refer to material in the Get Started with Eclipse in the Computer Lab tutorial mentioned above.
1. In Eclipse, what is the name of the file that stores a project's settings? (The project-settings file is different from the file that stores coding-style preferences.)
2. What button should you click to terminate the currently running program?
3. Why is it important to use monospace font for program source code in your homework document?
4. Answer this question AFTER you’ve completed the project part of this assignment:
What’s the hardest part of this project for you? Please explain.
PROJECT: Party Guest List (18 pts)
The purpose of this project is to review and practice:
· designing a class using UML class diagram
· building a class
· working with projects with one class and one driver class
Write a complete program that stores and prints number of participants in a party. As part of your program, write a Party class that implements these members:
· An instance constant that holds the maximum number of guests.
· Two instance variables that hold, respectively, the actual number of guests and the party host’s name.
· A constructor that stores the maximum number of guests and the host’s name, and initialize the actual number of guests to zero.
· An addGuest method that fakes adding a guest to the guest list by incrementing the actual number of guests by 1 or prints an error message if there’s no more room on the guest list (already full).
· A printParty method that prints the party’s host, actual number of guests, and the max number of spots.
Draw a UML class diagram for this Party class. Refer to the UML format in Fig 6.12 of our textbook, but without the driver class portion nor the local variables portion.
Provide a separate driver class that tests your Party class. Your driver class should contain this main method:
public static void main(String[] args)
{
Party party = new Party(3, "David Beckham");
party.addGuest("Roberto Baggio");
party.addGuest("Zinedine Zidane");
party.addGuest("Roberto Baggio");
party.addGuest("Johan Cruyff");
party.addGuest("Diego Maradona");
party.printParty();
} // end main
When compiled and run, your driver class and Party class together should produce this output:
Johan Cruyff cannot come to the party. The guest list is full.
Diego Maradona cannot come to the party. The guest list is full.
David Beckham's party: 3 guests out of 3 spots.
You may have realized that Party class allows a same guest added to the guest list for more than once, which is bad! This is a design flaw due to the limitation of our Java knowledge. Since we don’t know how to store multiple guest names of a party yet, there is no way to check if a guest is already registered. But don’t worry we will come back and fix this in a follow-up assignment after we learn about Array in ch9.
Overall comment your program appropriately. Pay attention to the standard stuff like coding style, indention, heading, and curly braces. Double check your code for indentation after you paste it in your document.
Submission
· In one word document: UML class diagram; source code; screenshot of running program
· Use the rubric below to check the completeness of your work before turning it in.
Rubric: CS219, HW1
|
Item |
Points (Max) |
Points (recvd) |
|
Exercise (2 pts) |
|
|
|
1 |
½ |
|
|
2 |
½ |
|
|
3 |
½ |
|
|
4 |
½ |
|
|
|
|
|
|
Project (14 pts) |
|
|
|
UML for Party class |
3 |
|
|
An instance constant that holds the maximum number of guests |
1 |
|
|
Two instance variables that hold, respectively, the actual number of guests and the party host’s name |
2 |
|
|
A constructor that stores the maximum number of guests and the host’s name, and initialize the actual number of guests to zero |
3 |
|
|
|
|
|
|
An addGuest method that increments the actual number of guests by 1 or prints an error message if there’s no more room on the guest list |
3 |
|
|
A printParty method that prints info of the party in the given format |
1½ |
|
|
|
|
|
|
The project contains two classes: Party class and a separate driver class |
½ |
|
|
|
|
|
|
General (4 pts) |
|
|
|
Your project compiles and runs |
½ |
|
|
Program output: correct result and format |
½ |
|
|
|
|
|
|
Programming style · Meaningful names for constants and variables · Correct indentation: 2 spaces for each level |
1
|
|
|
Comments · Prolog · End of section comments: end of class, end of method, end of loop etc. · Document each variable · Proper comments in the program |
2
|
|
|
|
|
|
|
Penalty |
|
|
|
Extra instance/class variables/methods |
(- 1) |
|
|
No copy of code in document |
(- 1) |
|
|
No screenshot of execution result |
(- 1) |
|
|
|
|
|
|
Total: |
20 |
|
- END -