|
@ -1,7 +1,9 @@ |
|
|
package org.bitbiome.commands; |
|
|
package org.bitbiome.commands; |
|
|
|
|
|
|
|
|
|
|
|
import org.bitbiome.shop.Item; |
|
|
import org.bitbiome.shop.Shop; |
|
|
import org.bitbiome.shop.Shop; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.Scanner; |
|
|
import java.util.Scanner; |
|
|
|
|
|
|
|
|
public class ShopCommand implements CommandAPI{ |
|
|
public class ShopCommand implements CommandAPI{ |
|
@ -12,16 +14,47 @@ public class ShopCommand implements CommandAPI{ |
|
|
System.out.println("Willkommen im Shop!"); |
|
|
System.out.println("Willkommen im Shop!"); |
|
|
System.out.println("Folgende Items sind aktuell im Shop:"); |
|
|
System.out.println("Folgende Items sind aktuell im Shop:"); |
|
|
shop.printCurrentShopItems(); |
|
|
shop.printCurrentShopItems(); |
|
|
System.out.println("Was willst Du hier im Shop?"); |
|
|
|
|
|
System.out.println("Etwas kaufen: 1"); |
|
|
|
|
|
System.out.println("Das Quiz spielen: 2"); |
|
|
|
|
|
System.out.println("Den Shop verlassen: 3"); |
|
|
|
|
|
|
|
|
ArrayList<Item> currentItems; |
|
|
|
|
|
|
|
|
while (true){ |
|
|
while (true){ |
|
|
|
|
|
System.out.println("Was willst Du hier im Shop?"); |
|
|
|
|
|
System.out.println("Etwas kaufen: 1"); |
|
|
|
|
|
System.out.println("Das Quiz spielen: 2"); |
|
|
|
|
|
System.out.println("Den Shop verlassen: 3"); |
|
|
|
|
|
|
|
|
String input = scanner.nextLine(); |
|
|
String input = scanner.nextLine(); |
|
|
if(validInput(input)){ |
|
|
if(validInput(input)){ |
|
|
if(input.equals("1")){ |
|
|
if(input.equals("1")){ |
|
|
//shop.buy(); |
|
|
|
|
|
|
|
|
currentItems = shop.currentShopItems; |
|
|
|
|
|
String inp = ""; |
|
|
|
|
|
System.out.println(""); |
|
|
|
|
|
System.out.println("Welches Item wollen Sie kaufen? "); |
|
|
|
|
|
for(int i = 0; i < currentItems.size(); i++){ |
|
|
|
|
|
System.out.println((i + 1) + " eingaben fuer " + currentItems.get(i).name + " | Kosten: " + currentItems.get(i).gold + " | Anzahl: " + currentItems.get(i).amount); |
|
|
|
|
|
} |
|
|
|
|
|
System.out.println("0 eingeben fuer eine andere Option."); |
|
|
|
|
|
|
|
|
|
|
|
while (true){ |
|
|
|
|
|
inp = scanner.nextLine(); |
|
|
|
|
|
if(inp.equals("0")){ |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
System.out.print("Anzahl eingeben: "); |
|
|
|
|
|
int existingCount = currentItems.get(Integer.parseInt(inp) - 1).amount; |
|
|
|
|
|
String inpAmount = scanner.nextLine(); |
|
|
|
|
|
if(Integer.parseInt(inpAmount) <= existingCount){ |
|
|
|
|
|
if(shop.buy(currentItems.get(Integer.parseInt(inp) - 1).name, Integer.parseInt(inpAmount))){ |
|
|
|
|
|
System.out.println(""); |
|
|
|
|
|
System.out.println("Vielen Dank fuer deinen Einkauf!"); |
|
|
|
|
|
System.out.println(""); |
|
|
|
|
|
break; |
|
|
|
|
|
}else { |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
}else { |
|
|
|
|
|
System.out.println("Error!"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} else if(input.equals("2")){ |
|
|
} else if(input.equals("2")){ |
|
|
//shop.quiz() |
|
|
//shop.quiz() |
|
|
} else if(input.equals("3")){ |
|
|
} else if(input.equals("3")){ |
|
|