Define a Product class with attributes: String productName, double price. Include the following methods: Encapsulate the fields override toString method Define a class called SimpleGrocery with the following attributes: array of Product. a) Add a default constructor that create the array of Product and initializes 10 products.

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

Java Program

See attached photo for the problem

You do not need to make the GUI, if you want to make it then you go. I only need the program of the circled problems in red color.

Define a Product class with attributes: String productName, double price.
Include the following methods:
Encapsulate the fields
override toString method
Define a class called SimpleGrocery with the following attributes: array of
Product.
Add a default constructor that create the array of Product and initializes
10 products.
a)
Create a new Frame with the components shown in the picture below.
combo box
Product Name
Quantity
Select Items
Price
label
Input quantity
text field
Buy
Compute
buttons
jTable
Total
label
Combo box – displays the product name from the array of products
Clicking the combo box displays the price of the selected product
Button Buy – add the selected product and the entered quantity in jTable. If the produ
is already existing in the jTable, the quantity is updated. For example shown below is the
existing data in the jTable. If another mango will be added, no row will be added in the jTable
instead the quantity will be updated.
Example existing data in jTable:
Product Name
Quantity
3
Mango
Button Compute – Calculates the total bill
jTable – clicking a row in the jTable displays a message with phrase “Are you sure you
want to delete the [display name of selected product]?" and Yes and No button. If the button
yes is clicked, the selected row in jTable is deleted and updates the total bilI.
Transcribed Image Text:Define a Product class with attributes: String productName, double price. Include the following methods: Encapsulate the fields override toString method Define a class called SimpleGrocery with the following attributes: array of Product. Add a default constructor that create the array of Product and initializes 10 products. a) Create a new Frame with the components shown in the picture below. combo box Product Name Quantity Select Items Price label Input quantity text field Buy Compute buttons jTable Total label Combo box – displays the product name from the array of products Clicking the combo box displays the price of the selected product Button Buy – add the selected product and the entered quantity in jTable. If the produ is already existing in the jTable, the quantity is updated. For example shown below is the existing data in the jTable. If another mango will be added, no row will be added in the jTable instead the quantity will be updated. Example existing data in jTable: Product Name Quantity 3 Mango Button Compute – Calculates the total bill jTable – clicking a row in the jTable displays a message with phrase “Are you sure you want to delete the [display name of selected product]?" and Yes and No button. If the button yes is clicked, the selected row in jTable is deleted and updates the total bilI.
Expert Solution
steps

Step by step

Solved in 3 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
  • SEE MORE 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