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, 21.06.2019 13:30
To remove a header or footer from a document you can open the header and footer and manually delete the content true or false
Answers: 1
question
Computers and Technology, 21.06.2019 21:00
You should hand write your references on your resume.
Answers: 1
question
Computers and Technology, 22.06.2019 12:40
The most complicated four letter word
Answers: 1
question
Computers and Technology, 23.06.2019 06:30
You are consulting for a beverage distributor who is interested in determining the benefits it could achieve from implementing new information systems. what will you advise as the first step?
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, 10.06.2021 01:00
question
World Languages, 10.06.2021 01:00
question
Mathematics, 10.06.2021 01:00
question
English, 10.06.2021 01:00
question
Biology, 10.06.2021 01:00
Questions on the website: 13722360