Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write Java program where it contains the following: A class to define a kind of objects in real - world ( i . e .

Write Java program where it contains the following:
A class to define a kind of objects in real-world (i.e. cars, chairs);
A main class (main program) to create an array of objects with 4 instances your class.
Assign different properties (attributes) to each element via the setters. And then get the
properties via the getters and output the properties to the console.
Basic Requirement:
You need to submit 2.java files: one for the class of a kind of real-world objects
and one for the main class;
Write your classes under a package named assign1;
Use the name convention: Assign1_pXXXXXXX as the class name of your main
No inner classes (e.g. a class declared in the main class);
For the class of real-world objects:
Define 2 properties of the class;
Explicitly define 1 constructor to initialize the properties with initial
values;
All the properties must be initialized with a value within the constructor.
You must not just let Java assign the default value to them;
Define a getter and a setter per each property, and 1 method for some
other behavior to the class (e.g. calculate the area of a circle by using the
radius). I.e. the total number of your class is 2+2+1=5.
Example Output:
A Rectangle class has 2 properties: width and height.
2 getters, 2 setters and 1 methods - getArea() are defined.
Output result:
image text in transcribed

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

Principles Of Database Systems With Internet And Java Applications

Authors: Greg Riccardi

1st Edition

020161247X, 978-0201612479

More Books

Students also viewed these Databases questions

Question

5. Understand how cultural values influence conflict behavior.

Answered: 1 week ago

Question

e. What do you know about your ethnic background?

Answered: 1 week ago