« All Events
6 PM – Intro To Java – Bill
March 28 @ 6:00 pm - 7:00 pm
Today We:
- Learned about how to create classes
Your HW:
- Create a new package called Mar_28_HW
- Create a Car class
- Attributes (all private):
- Brand (String)
- Model (String)
- Year (Int)
- Methods:
- Getters and Setters for the 3 attributes
- The Constructor with 3 parameters for the brand, model, and year
- drive
- void method
- 1 parameter miles
- will print out: “you drove the <year> <brand> <model> <miles parameter> miles”
- display
- will return the string in the format of “<Brand> <Model> – <Year>”
- Create a CarTester class
- this will have the main method that you will use to test the code
- Create 3 cars
- Ex: 2005 Honda Civic, 2024 Porsche 911, 2011 Chevy Camaro
- Display all 3 cars using the display method
- Drive all 3 cars 5 miles each