Instructor: Todd Dole
To begin learning how to create simple classes and objects. This exercise will be very similar to what we did in class with the Rectangle class, but using a class of your own choosing. This is a chance to get creative and build something unique!
For this assignment, you will create a class called ClassExperiment (saved as ClassExperiment.java).
Within that class, create a main method, but leave it blank for now.
Then, pick a type of object that you would like to model, and create a class for it. Examples: bicycles, music albums, school courses, sports teams, Pokemon cards or Dungeons and Dragons characters. Pick something that is creative and fun!
For your class, you will create the following:
For example, if we made a car class, we might have attributes like color, make, or model (which could all be String variables.) Or we might have a speed attribute (using a double).
We could create an accelerate method, which would increase the speed, a stop method which would set the speed to 0, and a displaySpeed method which would print out how fast the car is currently driving.
Try to come up with data and methods that are appropriate for your class/objects. myBicycle.stop() makes sense, dallasCowboys.stop() probably doesn't.
(Please don't use car as your actual class--this is just an example of the sorts of things you might create.)
Finally, return to your main method. In the main method, create two or more objects of your new class using the new keyword, and then do something fun with them! Set the attributes for each object, and call each of the methods at least once.