Answered You can hire a professional tutor to get the answer.

QUESTION

Attached is the class diagram needed to develop the code for these problems. Write the code for the ColorConstants interface.

Attached is the class diagram needed to develop the code for these problems.

1. Write the code for the ColorConstants interface. This interface should declare constants for the colors red, white, and black and assign the int values 1, 2, and 3 to those constants.

2. Write the code for the AutoReader interface. This interface should declare two methods. The first one, named getAuto, should accept an id and return an Automobile object for the automobile with that id. The second one, named getAutosByColor, should accept an integer that represents a color in the ColorConstant interface and return a string that contains the ids of all the automobiles that are that color.

3. Write the code for the AutoTextFile class. Simulate the getAuto method by creating a new Automobile object with the id that's passed to the method. Don't worry about setting the values of the other instance variables. Simulate the getAutosByColor method by using a switch statement to return a string of numbers depending on which color is specified (you choose the numbers). If an invalid color number is specified, return a null.

4. Write the code for the AutoDisplayApp class that uses the getAuto method defined in the AutoTextFile class to get an Automobile object with a specified if and then prints a message with the id in this format:

Auto 1234 read successfully.

5. Write the code that uses getAutosByColor method defined by the AutoTextFile class to get the ids for all the autos with a specified color. If one of more autos are found, a message should be printed in this format:

Red automobiles 1, 4, 7, 10

Otherwse, this message should be printed:

There are no automobiles with that color.

Assume that an int variable named color has already been declared and assigned a color value. Use the constants in the ColorConstants interface in your code.

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question