I need help with my Java homework

CSIT 254 – Project 1 – (Your own Class)Overview
Later this semester, you will be doing a number of labs and projects that are a collection of objects. Such
as a linked list of objects, stack of objects, queue of objects, tree of objects. Some of the projects will be
to maintain a ‘collection’ of objects where you will interact with the user to add, update, and delete
from the ‘collection’ of objects.
Although you will need to test your collection with a specific class from the instructor, you can use it
with a class of your own choosing.
For this Project, you are to create your own class as long as it isn’t a class that the instructor has
provided in the Demo Files or written by the instructor in class or any other class assigned. [ For
example: cannot be: Album, Artist, Car, Card, Cheese, Circle, Coin, Course, Cube, Food, Instructor, Pay,
Pizza, Rectangle, Song, TextBook, Trip, Truck, Vehicle. It also can’t be “inappropriate” such as Butt. ]
The class you create
• must have 2 private attributes of which at least one is a String and one is a numeric (int or
double)
(too many attributes ( > 3 ) is just busy work for yourself…It would be easier for future
labs/projects if the 2 attributes can uniquely identify an object)
• you need at least 1 constructor that will receive 2 parameters (to uniquely identify a specific
object)
o you can have a no-arg constructor and you can have additional constructors, but some
of the other labs/projects will require you to instantiate a unique object with
parameters
• You need setters and getters for each of the fields where applicable
[ Example: the Car class has a getSpeed() but doesn’t have a setSpeed() – it has brake() and
accelerate() both which affect speed ]
• Later in the semester, you will add the following additional methods to the class:
o equals( )
o compareTo( )
o if either of the prior methods are submitted as part of Project 1, they will be peeked at
but only graded in terms of indenting, variable names, javadoc
Extra Credit
Create a super-class and a sub-class where an instance of the sub-class has the minimal attributes
defined for the class above (at least 2 attributes one String and one numeric, at least 1 constructor with
at least 1 parameter). You can’t use Food and Cheese but similar to that superclass/subclass from Day 1.
1
CSIT 254 – Project 1 – (Your own Class)
For the driver:
• instantiate an instance of the class using hardcoded values
Example:
Soda mySoda = new Soda(“Coca-cola”, 2.29, 280);

Display the attributes from the object using the getters.
Example:
System.out.println(“Length: ” + kitchen.getLength());

prompt the user for the attributes (Scanner or JOptionPane)

Update the object using the setters
Example:
mySoda.setPrice(priceEntered);

Display the attributes from the object using the getters.
2
CSIT 254 – Project 1 – (Your own Class)
Class Ideas
If you can’t think of a good class some examples are: Guitars, Games, Sodas, Candy, Portals, Animals,
Pets, Zombie Pets, Magical Powers, Magical Zombie Powers, Weapons, Magical Zombie Pet Weapons,
Zombie Portals
If you still can’t think of a good class and are lost as to what to do, use this one:


Soda class
o attributes (private)
▪ name a String
▪ price a double
or calories as int
o The constructor would receive parameters:
▪ initialName a String
▪ initialPrice a double
or initialCalories as int
o The methods would be
▪ getName() returns a String
▪ getPrice() returns a double
or getCalories() returns an int
▪ setName() expects a parameter – a String
▪ setPrice()expects a parameter – a double
or setCalories() expects a parameter- int
Superclass/Subclass?
o Beverage as superclass with name and price
o Soda as subclass with calories
A Sample Run (using Soda class):
After instantiation…
Name: Coca-cola
Price: 2.20
Calories: 280
Enter new name for soda: Diet Coke
Enter new price for soda: 1.89
Enter new calories for soda 3
After updates…
Name: Diet Coke
Price: 1.89
Calories: 3
3
CSIT 254 – Project 1 – (Your own Class)
Grading Rubric for your Class file [ ClassName.java ]: (68 Points)









Comment in class with name (2 points)
following the naming guidelines for Classes and identifiers (8 points)
At least 2 private class fields created as requested (8 points)
(one a String and one numeric)
At least one Constructor created as requested receiving parameters (5 points)
setter/getter methods as appropriate (based on 4pts each – 16 points)
Comments in Javadoc format for constructor(s) and methods (15 points)
proper indenting (methods indented inside class, statements indented inside method) (8 points)
organization of your Class( instance variable up top / Constructor / then setters/getters )
(6 points)
Remember your project must compile and run in order to get any credit and it must be handed
in on time
Grading Rubric for driver [ Project1.java or ClassNameDriver.java or something like that]: (32 Points)







Comment in program with name (2 points)
Instantiation of object using hard-coded parameter (6 points)
Displaying values (console or JOptionPane) from object using the getters (6 points)
prompting the user (Scanner or JOptionPane) for the attributes of the object(6 points)
Update the object using setters using values from user (6 points)
Displaying values (console or JOptionPane) from object using the getters (6 points)
Deductions for:
o Up to -4 points for not following the naming guidelines for Classes and identifiers
o Up to -5 points for Improper indenting
o Remember your project must compile and run in order to get any credit and it must be
handed in on time
Submitting the Project
Attach your.zip file to the “Project 1” assignment in Canvas
Cheating and Late Policies
Please see the syllabus for the Cheating Policy (don’t cheat) and the project will not be accepted
late.
4

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper
Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER