java experts needed

profilegoodworkneeded
20150904001539item_list.docx

/**

* Item list. This contains the list of all items.

* The list should never contain a null in the middle and should never have a

* blank at the end (eg a null).

*/

private Item[] itemList = new Item[0];

/**

* NOTE DO NOT CREATE ANY OTHER VARIABLES HERE

*/

/**

* The number of coins in the inventory

*/

private int goldCoins=0;

/**

* Maximum carrying capacity

*

*/

double maximumCarryingCapacity = 0;

/**

* Maximum number of items;

*/

int maximumNumberOfItems = 0;

/**

* Name of inventory

*/

String name = null;

/**

* Increase the array by one. You will need to create a new array one element

* bigger than the old array.

* No External Classes Permitted to Be Used in This Method<p>

* My Solution Length in Lines (note yours can be longer or shorter): 4

*

*/

private void increaseArray() {

}

/**

* shrink the array by one. You will need to create a new array one smaller

* than the current one then copy the old one into the new one.

* This method should fail if the list is less than 1 in size, also if the last

* element is not null.

* No External Classes Permitted to Be Used in This Method<p>

* My Solution Length in Lines (note yours can be longer or shorter): 9

*

* @return true if it was successful false if unsuccessful

*/

private boolean decreaseArray() {

return false;

}

/**

* Return the item at the specific location in the list

* If the item doesn't exist return null.

* This does not modify the item list. It will return

* No External Classes Permitted to Be Used in This Method<p>

* My Solution Length in Lines (note yours can be longer or shorter): 5

*

* @param index the position to return.

* @return The item at index or null if no item

*/

//ALL METHODS FROM HERE ON ARE REMOVED YOU NEED TO ADD THEM IN.

/**

* Add gold to the inventory.<p>

* My Solution Length in Lines (note yours can be longer or shorter): 1

*

* @param amountToAdd add the gold to the inventory

*/

/**

* remove gold from inventory.

* If you ask for more than you got in the inventory

* return -1 to flag that its not possible to remove gold

* else remove the gold and return the amount you removed

* from the inventory.<p>

* My Solution Length in Lines (note yours can be longer or shorter): 6

*

* @param amountToRemove The amount of gold to remove from the inventory

* @return the amount removed unless it would have gone negative then -1

*/

/**

* Returns the current gold coins in the inventory

* Not tested in Junit<p>

* My Solution Length in Lines (note yours can be longer or shorter): 1

*

* @return amount of gold in kitty

*/

/**

* Adds the provided item to the array. You will need to increase

* the array size and add the new item to the end of the list. If the

* name already exists (case does not matter) don't add the item.

* No External Classes Permitted to Be Used in This Method Apart From

* String.toUpperClass and String.Equals

* If the item status is broken do not add it to the list<p>

* My Solution Length in Lines (note yours can be longer or shorter): 6

*

* @param newItem the item to be added

* @return the index of the new item -1 if newItem was null, null or its broken

*/

/**

* remove the item at the index.

* Pack the array and shrink the array when finished.

* No External Classes Permitted to Be Used in This Method<p>

* My Solution Length in Lines (note yours can be longer or shorter): 8

*

* @param index of the item to remove

* @return the item removed. If no item at the index return null.

*

*/

/**

* remove the item of name from the array.

* Pack the array and shrink the array when finished.

* case shouldn't matter.

* (Note that you should do this method by using other methods)

* No External Classes Permitted to Be Used in This Method<p>

* My Solution Length in Lines (note yours can be longer or shorter): 1

*

* @param nameOfItem The name of the item to be remove

* @return the item removed. If no item at the index return null.

*/

/**

* returns a list of broken items.

* if there are no broken items return an empty list.

* No External Classes Permitted to Be Used in This Method.<p>

* My Solution Length in Lines (note yours can be longer or shorter): 13

*

* @return a list of items that are broken. If there is nothing in the list return empty item array.

*/

/**

* Damage the particular item at the index. If the item is destroyed (eg damage greater

* than the durability of the item. The item should be left in the list with status updated to broken.

* No External Classes Permitted to Be Used in This Method Apart from String.equals.<p>

* My Solution Length in Lines (note yours can be longer or shorter): 3

*

* @param index the item to damage

* @param damage the amount of damage

* @return true if the item was broken false if not found or not broken

*/

/**

* find the item with the particular name.

* Leave the item in the list and get a copy.

* No External Classes Permitted to Be Used in This Method Apart from String.equals<p>

* My Solution Length in Lines (note yours can be longer or shorter): 3

*

* @param nameToBeFound the name of the item to be found

* @return the item with the name or null if not found

*/

/**

* Repair the item of the name.

*

* The item will be repaired only if there is enough gold in the inventory

* to pay for it.

*

* The cost of the repair is 25% of the lost value of the durability

* For example

* If you had a widget that was worth 1000 gold coins

* and it was at 60% durability then its current value is 600 gold coins.

* It has lost 400 gold coins in value due to wear.

* If you repair the item it will cost 100 gold coins (25% of 400 gold coins).

*

* If there is not enough gold to repair the item it should not repair the item

* at all and return false. Otherwise it should remove the gold coins from the

* inventory and return true.<p>

* My Solution Length in Lines (note yours can be longer or shorter): 3

*

* @param nameToBeRepaired the name of the item to be repaired

* @return true if successfully repaired false otherwise

*/

/**

* Repair the item at the index.

*

* The item will be repaired only if there is enough gold in the inventory

* to pay for it.

*

* The cost of the repair is 25% of the lost value of the durability

* For example

* If you had a widget that was worth 1000 gold coins

* and it was at 60% durability then its current value is 600 gold coins.

* It has lost 400 gold coins in value due to wear.

* If you repair the item it will cost 100 gold coins (25% of 400 gold coins).

*

* If there is not enough gold to repair the item it should not repair the item

* at all and return false. Otherwise it should remove the gold coins from the

* inventory and return true.<p>

* My Solution Length in Lines (note yours can be longer or shorter): 6

*

* @param index of the item to be repaired

* @return true if successfully repaired false otherwise

*/

/**

* Add an item to the inventory if there is enough gold coins to add it

* if there isn't. don't add the item and return false.

* The cost is based on the current Value of the item.<p>

* My Solution Length in Lines (note yours can be longer or shorter): 9

*

* @param newItem the item to be bought and added to inventory

* @return true if successfully added false otherwise

*/

/**

* Give the relative difference in value between two items to allow

* the caller to figure out if a trade is worth it.

* (note this method is static).

* Note that the first item is assumed to be yours so the value returned

* is how much you would be ahead if you do the trade<p>

* My Solution Length in Lines (note yours can be longer or shorter): 2

*

* @param myItem first item to compare

* @param theirItem second item to compare

* @return the difference in current values between item 1 and item 2 -1 if either were nulls

*/

/**

* Find the item on the inventory with the closest cost to the item

* being passed in. Remove the item being returned

* This is to simulate the person pulling out the item and looking at it.

* If they decide against the trade it they should re-add to the inventory

*

* Note the closest item should be the closest item under the price of the

* item to be traded. Eg the new value of itemToBeTraded is greater than the

* value of the item you return.

*

* if itemToBeTraded has a lower value to that to all items in the list return

* null.<p>

* My Solution Length in Lines (note yours can be longer or shorter): 15

* Difficulty: Hard

*

* @param itemToBeTraded the item to be compared to.

* @return the most expensive item in the inventory under the new value of itemToBeTraded. Null if none found

*/

/**

* Return the number of items in the list.

* No External Classes Permitted to Be Used in This Method<p>

* My Solution Length in Lines (note yours can be longer or shorter): 1

*

* @return the number of items

*/

/**

* return the index of the item with the given name. Case does not matter.

* No External Classes Permitted to Be Used in This Method Apart from

* String.Equals and String.ToUpperCase<p>

* My Solution Length in Lines (note yours can be longer or shorter): 6

*

* @param nameToBeFound the name of the item to be found

* @return the position of the searched for item. -1 if none found

*/

/**

* ADVANCED STUDENTS ONLY

*

* Sort the array by item name. Note that if you are not attempting this method

* you must still implement the method signature so that the test program will run.

* No External Classes Permitted to Be Used in This Method Apart From String.CompareToIgnoreCase<p>

* My Solution Length in Lines (note yours can be longer or shorter): 12

*

*/

public void sort() {

}

/**

* Creates a list of item with their hit points in the following form

*

* Item List

* 1. output of item toStringMethod

* 2. output of item toStringMethod

* 3. output of item toStringMethod

* 4. output of item toStringMethod

*

* Note the formatting is done so that the output lines up in the columns

* Please use the most appropriate classes to help you do this method.<p>

* My Solution Length in Lines (note yours can be longer or shorter): 5

*

*/

public String toString() {

String value = "";

for (int i=0;i<itemList.length;i++) {

value += itemList[i].toString()+"\n";

}

return value;

}

/**

* Debug function for testing that things are working ok.

* Dumps a printout of the current state of the item array

*/

private void dumpAll() {

for (int i=0;i<itemList.length;i++) {

System. out .println(itemList[i]);

}

}

/**

* Don't mess with this value

*/

public static String encoodeID = "38347575739292F2";

}