You work for a company that has warehouses of items. The items are all packaged in boxes that are roughly the same size. Each warehouse has some shelves in it. The shelves all hold the same number of boxes. To keep things from getting confusing, a shelf will only contain one kind of item on it, and a warehouse will have at most one shelf storing a given kind of item. (If the shelf is full, that item would go to a different warehouse to make sure that items are evenly distributed, but your code won’t track multiple warehouses.) You will create a Warehouse class to simulate a warehouse according to the above description. If you would like to make use of another class of your design, declare it inside the Warehouse class (this is called an inner class). It is possible to create an efficient solution without having to do this. You can imagine each shelf sitting in a long line; what kind of data structure have we seen that can take advantage of this? If each shelf has multiple properties, the shelf’s location could be used to access different properties of the same shelf in different data structures. The constructor will be given the number of shelves and the number of items which are held per shelf. When the warehouse is constructed, the shelves are empty. The get methods will report back the shelf count and capacity that the warehouse was constructed with. The constructor and get method declarations are defined below: public Warehouse(int shelfCount, int shelfCapacity) public int getShelfCount() public int getShelfCapacity() Your warehouse object will have a method to receive a truckload. A truckload will have only one kind of item (represented by an item code number) as well as the number of boxes of that item. You will load as many boxes as you can of that item given the above rules and return the number of boxes left on the truck (not loaded). public int receive(int itemCode, int itemCount) Your warehouse object will have a method to ship an item. The shipment request will contain the item code as well as the number of boxes requested. The warehouse will ship out as many as it can, up to the amount requested. Your method will return the number of boxes shipped of that item. public int ship(int itemCode, int itemCount) Both the receive and ship methods will have to update the internal tracking of items as items are received and shipped out. Different warehouses operate independently of each other and can have similar or entirely different sets of items. (The info here is important) when you run your code, the sample below should be given You may assume that every integer (shelf count, shelf capacity, item code, and item count) given to your methods is greater than 0. Suppose you create Warehouse A with room for 3 pallets but only allowing 2 of any item: Warehouse A = new Warehouse(3, 2); Warehouse A then receives 3 pallets of item 1. You can only hold 2 of any item, so your method returns 1 to say that it left one behind: A.receive(1, 3) returns 1 Warehouse A receives 1 pallet of item 2. Your method returns 0 to say it left nothing behind: A.receive(2, 1) returns 0 Warehouse A is requested to ship 1 pallet of item 1. Your method returns 1 to say that it shipped that one pallet: A.ship(1, 1) returns 1 Warehouse A receives 2 pallets of item 1. Your method returns 1, since it leaves 1 behind after fitting 1 (which happens to be under the limit). Warehouse A receives 1 pallet of item 4. Your method returns 1 – it has no room so it leaves that one behind. Warehouse A is requested to ship 2 pallets of item 1. Your method returns 2 to say it shipped the last 2 pallets of the item requested. Warehouse A receives 2 pallets of item 2. Your method returns 1, since it already had one, so it only store one more

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

You work for a company that has warehouses of items. The items are all packaged in boxes that are roughly the same size. Each warehouse has some shelves in it. The shelves all hold the same number of boxes. To keep things from getting confusing, a shelf will only contain one kind of item on it, and a warehouse will have at most one shelf storing a given kind of item. (If the shelf is full, that item would go to a different warehouse to make sure that items are evenly distributed, but your code won’t track multiple warehouses.)

You will create a Warehouse class to simulate a warehouse according to the above description. If you would like to make use of another class of your design, declare it inside the Warehouse class (this is called an inner class). It is possible to create an efficient solution without having to do this. You can imagine each shelf sitting in a long line; what kind of data structure have we seen that can take advantage of this? If each shelf has multiple properties, the shelf’s location could be used to access different properties of the same shelf in different data structures.

The constructor will be given the number of shelves and the number of items which are held per shelf. When the warehouse is constructed, the shelves are empty. The get methods will report back the shelf count and capacity that the warehouse was constructed with. The constructor and get method declarations are defined below:

public Warehouse(int shelfCount, int shelfCapacity) public int getShelfCount()
public int getShelfCapacity()

Your warehouse object will have a method to receive a truckload. A truckload will have only one kind of item (represented by an item code number) as well as the number of boxes of that item. You will load as many boxes as you can of that item given the above rules and return the number of boxes left on the truck (not loaded).

public int receive(int itemCode, int itemCount)

Your warehouse object will have a method to ship an item. The shipment request will contain the item code as well as the number of boxes requested. The warehouse will ship out as many as it can, up to the amount requested. Your method will return the number of boxes shipped of that item.

public int ship(int itemCode, int itemCount)

Both the receive and ship methods will have to update the internal tracking of items as items are received and shipped out. Different warehouses operate independently of each other and can have similar or entirely different sets of items.

(The info here is important)

when you run your code, the sample below should be given

You may assume that every integer (shelf count, shelf capacity, item code, and item count) given to your methods is greater than 0.

Suppose you create Warehouse A with room for 3 pallets but only allowing 2 of any item:

Warehouse A = new Warehouse(3, 2);

Warehouse A then receives 3 pallets of item 1. You can only hold 2 of any item, so your method returns

1 to say that it left one behind:

A.receive(1, 3) returns 1

Warehouse A receives 1 pallet of item 2. Your method returns 0 to say it left nothing behind:

A.receive(2, 1) returns 0

Warehouse A is requested to ship 1 pallet of item 1. Your method returns 1 to say that it shipped that

one pallet:

A.ship(1, 1) returns 1

Warehouse A receives 2 pallets of item 1. Your method returns 1, since it leaves 1 behind after fitting 1

(which happens to be under the limit).

Warehouse A receives 1 pallet of item 4. Your method returns 1 – it has no room so it leaves that one

behind.

Warehouse A is requested to ship 2 pallets of item 1. Your method returns 2 to say it shipped the last 2

pallets of the item requested.

Warehouse A receives 2 pallets of item 2. Your method returns 1, since it already had one, so it only

store one more

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Probability Problems
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