Question
Java Object Oriented Programming OOP Encapsulation: Creating Your Own Class with Java ---------------------------------------------------------------------------------------------------- Write a Java application, and an additional class to represent some real-world
Java Object Oriented Programming
OOP Encapsulation: Creating Your Own Class with Java
----------------------------------------------------------------------------------------------------
Write a Java application, and an additional class to represent some real-world entity such as a technology item, an animal, a person, a vehicle, etc. Keep in mind that a class is a model in code of something real or imagined, which has attributes (member variables) and behaviors (member methods).
Note: I will go through and post examples of a SmartPhone class and a FootballPlayer class in class, so choose something other than these.
The class will:
a. Create a total of 5 member variables for the class, selecting the appropriate data types for each field. For example, a class to represent a lamp might include color, price, height, numBulbs, batteryOperated. Each of these 5 variables need a data type.
b. Include at least three different constructor methods, in addition to the default constructor (0 argument constructor). The constructor is a function (method) which allocates memory and initialized the member variables specified in (a.).
c. Include getters/setters for to serve as as mutators and accessors for each variable. Name these appropriately such as setColor & getColor, setPrice & getPrice, setHeight & getHeight, setNumBulbs and getNumBulbs, and setBatteryOperated & getBatteryOperated.
d. Create a member function showValues() to display the values of an object in a formatted manner.
e. Create at least 2 other member functions (methods) for the class that will perform some operation on the data (i.e. calculations or additional report/display of output). For example, turnLampOn, changeBulb, etc.
The Java application class (with a main method) will:
a. Instantiate at least three objects (using each of the constructors at least once) with your program. Note: Set the remaining data with the mutator methods.
b. Store the data from the individual objects into an ArrayList (or some other dynamic data structure of objects.
c. Utilize the showValues() method and each of the two methods on each of your objects to demonstrate their use.
Required Output: Generate output samples demonstrating all of your member functions, adequately testing them and showing their functionality (i.e. inputting values, outputting values (displaying them), performing calculations, etc.).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started