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, 22.06.2019 12:10
1. declare a constant named cents_per_pound and initialize with 25. 2. get the shipping weight from user input storing the weight into shipweightpounds. 3. using flat_fee_cents and cents_per_pound constants, assign shipcostcents with the cost of shipping a package weighing shipweightpounds.
Answers: 2
question
Computers and Technology, 22.06.2019 18:30
All of the following are characteristics that must be contained in any knowledge representation scheme except
Answers: 3
question
Computers and Technology, 24.06.2019 10:30
You're programming an infinite loop. what must you include in your code to prevent crashes? in roblox
Answers: 2
question
Computers and Technology, 25.06.2019 04:30
You can fit more raw files on a memory card than the jpeg files? truefalse
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
Geography, 05.02.2020 09:59
question
Mathematics, 05.02.2020 09:59
question
Mathematics, 05.02.2020 09:59
Questions on the website: 13722361