CMPSCI111L
Project 4
Skip To Content
Dashboard
  • Login
  • Dashboard
  • Calendar
  • Inbox
  • History
  • Help
Close
  • My Dashboard
  • CMPSCI111L
  • Assignments
  • Project 4
2017FA
  • Home
  • Assignments
  • Syllabus
  • Quizzes
  • Collaborations
  • Library
  • The Learning Center
  • McGraw Hill Campus
  • Google Drive
  • Campus Resource Guide
  • EvaluationKIT Course
  • Online Tutoring
  • Services for Students
  • Employment Center
  • Office 365
  • Canyons Connects
  • Purchase Course Materials
  • Top Hat
  • Zoom
  • Lucid (Whiteboard)
  • Insights-Beta
  • Credentials
  • Insights

Project 4

  • Due Oct 27, 2017 by 11am
  • Points 30
  • Submitting on paper
  • Available Oct 20, 2017 at 12am - Oct 27, 2017 at 11:59pm
This assignment was locked Oct 27, 2017 at 11:59pm.

Computer Science 111 Introduction to Algorithms and Programming: Java

Programming Project #4 – Classes and Objects (30 Points)

 

You will create 3 new classes for this project, two will be chosen from the list below and one will be an entirely new class you invent. Here is the list:

Shirt

Shoe

Wine

Book

Song

Bicycle

VideoGame

Plant

Car

FootBall

Boat

Computer

WebSite

Movie

Beer

Pants

TVShow

MotorCycle

Design First (5 points)

Create three (3) UML diagrams for three classes. Two of the classes are assigned by the instructor from the above list and one you must invent. Choose as the third class, something you know very well or love doing. If soccer is your favorite sport, create a class Soccer. If you sing opera, create a class Opera. Do not overthink. Just come up with the 3 most important data members (i.e. global variables) that describe the class/object you want to build and the design 2 constructors, 3 get methods, 3 set methods and a toString method and you are done.

Please do not use the same 3 data types for any classes global variables. That is, do not make them all ' int ' or all ' String '.

Next to each UML diagram decide on a default value, minimum value and a maximum value for EACH numeric variable. For example, the Shoe class and its size variable may have a default value of 0; the minimum size may be 1 and the maximum size 15. A String variable may set a default value of null, and a minimum and maximum length of the String. For example, the Computer class and its brand variable may have a default value of null, a minimum string length of 3 and the maximum length 20. Please do not use the same 3 data types for any classes global variables. That is, do not make them all ' int ' or all ' String '.

Implement Next (25 points)

Create a NetBeans project. Create a Java file for EACH of the three classes. For example, add to your project a new file called Book.java   and then create the new class from scratch in that file. Use your UML diagrams as the guideline for writing the code. The variables and methods from the diagrams will be part of each of your classes. Make sure ALL your variables are declared to be private.

Protect Your Data!

Objects store data or information! When variables are declared private you can protect or guard that information like a Pit Bull protects a piece of meat. Never allow bad data to be stored in your objects! In each 'set' method, make sure the value passed to the method is in range, greater than or equal to the minimum and less than or equal to the maximum. For strings, you may check the length of the string. Each 'set' method should have some sort of 'if-else' statement, assign the data when it is good and print an informative message when an incorrect value is passed. The Shoe class setSize() method would assign the value '10' to the size global variable when it is passed to the method. But, it would print a 'Shoe size must be between 1 and 15' and NOT change the global variable when a value such as '437' was passed to the method. The private variable declarations build a wall around your data, and the 'set' methods are the gates that allow only 'good' information in. Your constructor that assigns values to global variables should use the 'set' methods so you DO NOT have to repeat the same checks in the constructor. The constructor with NO parameters can go ahead and directly set the default values into the global variables.

Test Next

For each class, create a main method that will declare, build and use an object of that class. So the Book.java   main will declare, build and use a Book object, and the other two classes will do the same. Use a command line interface and ask the user to input a value for EACH global variable. Call a constructor or the set methods and insert that information into the object. Once the data is inserted use the object to call the toString method and print the object to the console. You will be writing THREE main methods, one for each class. When you test, make sure your set methods DO NOT allow bad data into the object. Try to make it fail, see if you can sneak bad values into the variables.

To insure you complete each class, use this checklist:

_____  Three global variables (not the same type)

_____  Two constructor methods

_____  Three 'get' methods

_____  Three 'set' methods

_____  One 'toString' method

_____  One main method that creates an object, assigns values, and prints the object

1509127200 10/27/2017 11:00am
Please include a description
Additional Comments:
Rating max score to > pts
Please include a rating title

Rubric

Find Rubric
Please include a title
Find a Rubric
Title
You've already rated students with this rubric. Any major changes could affect their assessment results.
 
 
 
 
 
 
 
     
Can't change a rubric once you've started using it.  
Title
Criteria Ratings Pts
This criterion is linked to a Learning Outcome Description of criterion
threshold: 5 pts
Edit criterion description Delete criterion row
5 to >0 pts Full Marks blank
0 to >0 pts No Marks blank_2
This area will be used by the assessor to leave comments related to this criterion.
pts
  / 5 pts
--
Additional Comments
This criterion is linked to a Learning Outcome Description of criterion
threshold: 5 pts
Edit criterion description Delete criterion row
5 to >0 pts Full Marks blank
0 to >0 pts No Marks blank_2
This area will be used by the assessor to leave comments related to this criterion.
pts
  / 5 pts
--
Additional Comments
Total Points: 5 out of 5