Create a class Person to represent a person according to the following requirements: A person has two attributes: id Add a constructer to initialize all the attributes to specific values. Add all setter and getter methods. 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). Add a constructer without parameters to initialize all the attributes to default values (0 for numbers, "" for a string and null for object). Add a second constructer to initialize all the attributes to specific values. Use the keyword "this". Add the method changePrice that change the price of a product. The method must display an error message if the given price is negative. Add a static method changeShopName to change the shop name. Add all the getter methods. The method getOwner must return an owner. Create the class ProductTester with the main method. In this class do the following: Create a person p1. The person’s name and id must be your name and your student Id. Create a product with the following information: reference = 1. price = a value from your choice. owner = p1. shopName = "SEU". Change the price of the product to your age. Change the shop name to your full name. Print all the information of the product.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
  1. Create a class Person to represent a person according to the following requirements: A person has two attributes:
  • id
  •  
  1. Add a constructer to initialize all the attributes to specific values.
  2. Add all setter and getter methods.
  3. 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).

 

  1. Add a constructer without parameters to initialize all the attributes to default values (0 for numbers, "" for a string and null for object).
  2. Add a second constructer to initialize all the attributes to specific values. Use the keyword "this".
  3. Add the method changePrice that change the price of a product. The method must display an error message if the given price is negative.
  4. Add a static method changeShopName to change the shop name.
  5. Add all the getter methods. The method getOwner must return an owner.
  6. Create the class ProductTester with the main method. In this class do the following:
  7. Create a person p1. The person’s name and id must be your name and your student Id.
  8. Create a product with the following information:

reference = 1.

price = a value from your choice.

owner = p1.

shopName = "SEU".

  1. Change the price of the product to your age.
  2. Change the shop name to your full name.
  3. Print all the information of the product.
4 Bluel: P
A BlueJ: Terminal Window.
Project Edit
Tools
View
Help
Options
New Class.
Person
product information
Reference: 1
Price: 28.0
Compile
Product
Owner:
id: 123456789
ProductTester
Name: Mohammed
Shop name: Mohammed Abdullah
Can only enter input while your pro
Transcribed Image Text:4 Bluel: P A BlueJ: Terminal Window. Project Edit Tools View Help Options New Class. Person product information Reference: 1 Price: 28.0 Compile Product Owner: id: 123456789 ProductTester Name: Mohammed Shop name: Mohammed Abdullah Can only enter input while your pro
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education