Hi guys my problem is pretty much as follows...
the following is happening when i try access the code, the first part is good because without having the handbag in inventory i want it to say you are carrying however if i have the handbag i want it to say you are carrying these items in your handbag but the below happens;
What now?
get
torch ok
What now?
list
You are carrying: torch
What now?
go
stairs It's dark in here!
What now?
get
handbag ok
What now?
list
You are carrying these items in your handbag:
torch
You are carrying these items in your handbag:
wallet
You are carrying these items in your handbag:
keys
You are carrying these items in your handbag:
ring
You are carrying these items in your handbag:
USB
You are carrying these items in your handbag:
mobile
You are carrying these items in your handbag:
handbag
and here is the code
can you help... thanks (this is java obviously)
sorry for being vague... pretty much when i dont have the handbag i want it to list what im carrying by saying 'you are carrying' however if i pickup the handbag at a point when thats picked up... i want it to say 'you are carrying these items in your handbag' but currently it prints out you are carrying just once... but you are carrying these items in your handbag is printed in everyline... i only want it once.
the following is happening when i try access the code, the first part is good because without having the handbag in inventory i want it to say you are carrying however if i have the handbag i want it to say you are carrying these items in your handbag but the below happens;
What now?
get
torch ok
What now?
list
You are carrying: torch
What now?
go
stairs It's dark in here!
What now?
get
handbag ok
What now?
list
You are carrying these items in your handbag:
torch
You are carrying these items in your handbag:
wallet
You are carrying these items in your handbag:
keys
You are carrying these items in your handbag:
ring
You are carrying these items in your handbag:
USB
You are carrying these items in your handbag:
mobile
You are carrying these items in your handbag:
handbag
and here is the code
Code:
public void listWhatYouHave() { for (int i = 0; i < 7; i++) { if (hasItem[6]) { System.out.println("You are carrying these items in your handbag:"); switch (i) { case 0: System.out.println("torch"); break; case 1: System.out.println("wallet"); break; case 2: System.out.println("keys"); break; case 3: System.out.println("ring"); break; case 4: System.out.println("USB"); break; case 5: System.out.println("mobile"); break; case 6: System.out.println("handbag"); break; default: System.out.println("invalid item!"); break; } } else if (hasItem[i]) { System.out.println("You are carrying:"); switch (i) { case 0: System.out.println("torch"); break; case 1: System.out.println("wallet"); break; case 2: System.out.println("keys"); break; case 3: System.out.println("ring"); break; case 4: System.out.println("USB"); break; case 5: System.out.println("mobile"); break; case 6: System.out.println("handbag"); break; default: System.out.println("invalid item!"); break; } } }
sorry for being vague... pretty much when i dont have the handbag i want it to list what im carrying by saying 'you are carrying' however if i pickup the handbag at a point when thats picked up... i want it to say 'you are carrying these items in your handbag' but currently it prints out you are carrying just once... but you are carrying these items in your handbag is printed in everyline... i only want it once.
Comment