Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean addItem(IItem item, IPosition position, Color color) throws ContainerException {
- boolean added = false;
- if (item != null && position != null) {
- if (this.closed) {
- throw new ContainerImplException("The container definition is invalid!");
- } else {
- if (this.find(item) == -1) {
- if (this.itemsPackedCounter == this.itemsPacked.length) {
- ItemPacked[] itemsPacked_temp = new ItemPacked[this.itemsPacked.length * 2];
- for(int i = 0; i < this.itemsPacked.length; ++i) {
- itemsPacked_temp[i] = this.itemsPacked[i];
- }
- this.itemsPacked = itemsPacked_temp;
- }
- this.occupiedVolume += item.getVolume();
- this.itemsPacked[this.itemsPackedCounter++] = new ItemPacked(item, position, color);
- added = true;
- }
- return added;
- }
- } else {
- throw new ContainerImplException("The container definition is invalid!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement