subject

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.

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

Here is example scenario:

Suppose you create Warehouse A with 3 shelves having capacity of 2 items each:

Warehouse A = new Warehouse(3, 2);
Warehouse A then receives 3 boxes of item 1. You can only have one shelf containing any item, so your method returns 1 to say that it left one behind:
A. receive(1, 3) returns 1

Warehouse A receives 1 box 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 box of item 1. Your method returns 1 to say that it shipped that one box:
A. ship(1, 1) returns 1

Warehouse A receives 2 boxes of item 3. Your method returns 0.
Warehouse A receives 1 box of item 4. Your method returns 1 – it has no empty shelves.

Warehouse A is requested to ship 3 boxes of item 1. Your method returns 1 to say it shipped the last box of the item requested.

Warehouse A receives 2 boxes of item 4. Your method returns 0 – it now has an empty shelf and can hold both boxes.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 16:00
Kenny works with an it company. his company is about to launch new software in the market. he has to ensure that this new software is functional and meets all of the quality standards set up at the planning stage. which job profile is kenny likely to have? kenny is likely to have the job profile of a blank .
Answers: 2
question
Computers and Technology, 24.06.2019 08:30
Why might you choose to create a functional resume
Answers: 1
question
Computers and Technology, 24.06.2019 21:40
Which of these is not a type of socket? aga (alternating grid array) pga (pin grid array) spga (staggered pin grid array) lga (land grid array)
Answers: 1
question
Computers and Technology, 24.06.2019 22:30
To include a watermark or page border on a word document, you will first need to navigate to the tab. file home insert design
Answers: 1
You know the right answer?
You work for a company that has warehouses of items. The items are all packaged in boxes that are ro...
Questions
question
Mathematics, 20.09.2019 11:30
Questions on the website: 13722360