Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 2 ( Objects , Classes, and Aggregation ) Consider the following system specifications: The system stores information about two things: cars and their owners.

Problem 2(Objects, Classes, and Aggregation)
Consider the following system specifications:
The system stores information about two things: cars and their owners. A car has attributes for
make, model, and year, and price. The car owner has attributes for name and address. Assume
that a car must be owned by one owner, and an owner can own many cars, but an owner might
not own any cars (perhaps the owner just sold them all, but we still want a record of that owner
in the system).
Create the two classes, Car and CarOwner with two constructors in each class, a default
constructor and another constructor that initializes attributes to arbitrary values to be known
when the object is constructed.
For each instance variable (attribute), create a set and get methods. The setter method one will be
used to set the value of the instance variable and the getter method will be used to get (return) the
current value of the instance variable. Also, make sure to use the toString() method whenever
appropriate to translate the objects state into text
Now, write a client program named UseCar that demonstarates the systems cababilities and
tests the methods in your classes. In this program, create an array list of cars and store in it at
least three car objects. Display the contents of this array (produce a nicely formatted description
of each car object such as cars make, model, year, price, and the cars owner information).
For this problem, you will also need to submit a UML class diagram showing the classes and the
relationship between these classes

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Accounting

Authors: Peter J. Eisen

5th Edition

0764135473, 9780764135477

Students also viewed these Databases questions