Question: Create a Java project in Eclipse or in NetBeans called hw1 and a class called Vehicle in it containing the main method. In comments at

Create a Java project in Eclipse or in NetBeans called hw1 and a class called Vehicle in it containing the main method. In comments at the top of the file include your name, the name of (A) Attributes: *) Add instance attributes to the class to store the following information: the type of vehicle - as a string (car, scooter, bus, etc.) the number of wheels - as an integer the fabrication year - as an integer the color - as a string *) Also add a class attribute (static) called scan of type Scanner, initialized from System.in. Check what you did in Lab Assignment #1 for more details. (B) Constructors: Create a constructor for the class with parameters for all four attributes. In the constructor, assign the values to the respective attributes. Also, create a default constructor that takes no parameters and initializes the number attributes to 0 and the string attribute to an empty string. (C) Input/Output: Write two public methods (input, output) of type void with no parameters. In the input method, ask the user for values for each attribute value and accept them using the scanner. For the output method, print to the terminal all the values of the attributes, nicely formatted.

C211 Spring 2022 Homework Assignment #1 p.2 (D) Comparison: Write two methods to compare two vehicle objects, name the methods isBigger and isNewer. Both methods should be public methods of type boolean. Both of them should take one parameter of class vehicle and compare it to the target object. For isBigger, if the target object has more wheels than the parameter the method should return true. Otherwise, it should return false. For the isNewer method, if the target objects year is newer (a larger integer) than the parameters year, return true. Otherwise, return false. Remember, the attributes of the target object can be accessed with their name only (no class needs to be specified). Do NOT have the parameter name be the same as the attribute name. This negates the need to use the format this.attribute. (E) Test: In the main, declare two objects of type Vehicle. For the first object, use the default constructor. For the second object, use the constructor with parameters and enter any values you want for them. After that, input the first object attribute values by calling the method input, and then output both objects. Then call the methods isBigger and isNewer from the first object with the second object as parameter, and output an appropriate message based on whether the methods return true or false. An example message would resemble the following: The first vehicle is newer than the second vehicle.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!