Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

*Programming with Java* You are required to write and use some user-defined clas

ID: 3679053 • Letter: #

Question

*Programming with Java*

You are required to write and use some user-defined classes. Here is what is given. A cell phone object has three attributes, a brand (String), a serial number (long), and a price (double).

Part 1:
You are required to design and implement the CellPhone class according to the following specifications:

- Upon the creation of a cell phone object, the object must immediately be initialized with valid values; that is brand, serial number and price.

- The design should allow enough flexibility so that the value of any of these attributes can be modified later on. For example, it should be possible to create a cell phone object with a given price then change its price later on.

- The design should allow the user of the class to obtain the value of any of the attributes individually. The design should also allow the user to view all cell phone information at once by passing cell phone objects to the print/println() methods;

- The design should allow for one cell phone to be compared to another cell phone for equality. Two cell phone objects are considered equal if they have the same brand and the same price.

Part 2:
In that part, you are required to write a public class called UtilizeCellPhones, which is going to utilize the CellPhone class that you have created in part1. In the main method of this class, you should perform the following operations:

1) Create three cell phone objects; notice that you must assign a brand, serial number (you can initialize it as any 9-digit number) and a price to each of these objects upon creation.

2) Show all information of each of the three objects.

3) Changethepriceofthefirstobject;thepriceandthebrandofthesecondobject,andthe

serial number value of the third object.

4) Display only the modified attributes of the three objects. All outputs showing only the

price of a cell phone (i.e. not the rest of the attributes) must be formatted.

5) Compare some of these cell phone objects for equality and display whether or not they

are equal.

Explanation / Answer

Please find the code below :

----------------------------------------------------------

OUTPUT:

CellPhone{brand='Nokia', serialNumber=123456789, price=10000.0}
CellPhone{brand='Samsung', serialNumber=839826389, price=25000.0}
CellPhone{brand='iPhone', serialNumber=719456284, price=60000.0}
12000.0
23000.0, Microsoft
738916373
false