Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using java Create three classes - Product with fields name (String) and quantity (of type int); - Box with fields id (String) and prods -

image text in transcribed

using java

Create three classes - Product with fields name (String) and quantity (of type int); - Box with fields id (String) and prods - array of Products; - Storage with only one field boxes - array of Boxes. All fields must be private. Provide necessary constructors and getters. In class Storage add a method totQuant which counts (and returns as an int) the total quantity of product the name of which (String) is passed as an argument to the method. In a separate class define function main public static void main (String [] args) \{ Box box1 = new Box("Box1", new Product [] new Product("Carrot", 15), new Product("Apples", 20) \}); Box box2 = new Box("Box2", new Product []\{ new Product ("Potato", 10), new Product ("Carrot", 12) \}); Storage sto = new Storage( new Box[] \{box1, box2\}); System. out.println("Tot. quantity of product: " + s sto.totQuant("Carrot")); which, for this example, should print Tot. quantity of product: 27

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions

Question

What are the attributes of a technical decision?

Answered: 1 week ago

Question

How do the two components of this theory work together?

Answered: 1 week ago