Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using Java Language make the following 1. Create a class Person to represent a person according to the following requirements: A person has two attributes:
Using Java Language make the following
1. Create a class Person to represent a person according to the following requirements: A person has two attributes: id name. a) Add a constructer to initialize all the attributes to specific values. b) Add all setter and getter methods. 2. Create a class Product to represent a product according to the following requirements: A product has four attributes: - - - a reference number (can't be changed) a price an owner (is a person) | a shopName (is the same for all the products). a) Add a constructer without parameters to initialize all the attributes to default values (0 for numbers, "" for a string and null for object). b) Add a second constructer to initialize all the attributes to specific values. Use the keyword "this". c) Add the method changePrice that change the price of a product. The method must display an error message if the given price is negative. d) Add a static method changeShopName to change the shop name. e) Add all the getter methods. The method getOwner must return an owner.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Solutions 1 Person class is created with the constructor and the settergetter for the class properti...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