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.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 10PE
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT