hello,

i have a java game but i have a problem with healing i get the error client.java:2791: orphaned case
case 315:
^
1 error
files compiled successfully!

this is the code:

public boolean healing()
{
		boolean eat = false;
		int heal = 0;
		
	        case 315:
		        Message("You eat the shrimps.");
			eat = true;
			heal = 3;
			break;		

		case 379:
			Message("You eat the lobster.");
			eat = true;
			heal = 12;
			break;
		
		case 385:
			Message("You eat the shark.");
			eat = true;
			heal = 20;
			break;
		
		case 7946:
			Message("You eat the monkfish.");
			eat = true;
			heal = 16;
			break;
		
		case 6685:
			Message("You drink a dose of the foul liquid.");
			eat = true;
			heal = 16;
			break;
		
		case 6687:
			Message("You drink a dose of the foul liquid.");
			eat = true;
			heal = 16;
			break;
		
		case 6689:
			Message("You drink a dose of the foul liquid.");
			eat = true;
			heal = 16;
			break;
		
		case 6691:
			Message("You drink a dose of the foul liquid.");
			eat = true;
			heal = 16;
			break;
		
		case 391: 
			Message("You eat the manta ray.");
			eat = true;
			heal = 24;
			break;

		if (eat) {
			anim(829);
			deleteItem(Item, Slot, 1);
			if (playerLevel[3] < getLevelForXP(playerXP[playerHitpoints])) {
				if (Item == 385 || Item == 391 || Item == 7946 || Item == 379 || Item == 315) {
					Message("It heals some health.");
				}
			}
			UpdateHP(heal);
			if (Item == 6685) {
				Message("You have 3 doses of potion left.");
				addItem(6687, 1);
			}
			if (Item == 6687) {
				Message("You have 2 doses of potion left.");
				addItem(6689, 1);
			}
			if (Item == 6689) {
				Message("You have 1 dose of potion left.");
				addItem(6691, 1);
			}
			if (Item == 6691) {
				Message("You have finished the potion.");
				addItem(229, 1);
			}
			Fighting = 3000;
			PkingDelay = System.currentTimeMillis();
			IsDead = false;
		}
		updateRequired = true;
		appearanceUpdateRequired = true;
		
}

Recommended Answers

All 4 Replies

pleas, idk what to do!

You can only have a "case" as part of a "switch".

srry idk what you mean i am a nubbie......

You have a number of "case" statements. Java language says you can only have a "case" as part of a "switch". You don't have a "switch" statement. I don't know how to make this clearer. Google Java switch.
Ps I'm on a proper PC, not a mobile phone, so you don't need to speak in text message code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.