0% found this document useful (0 votes)
200 views1 page

Java Fruit Catching Game

This Java code defines a FruitsBasket class with a main method that uses a stack to simulate catching different fruits. The program prompts the user to enter how many fruits they want to catch and then to select each fruit by letter from a list of options to add to the stack, simulating catching multiple fruits in a basket.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
200 views1 page

Java Fruit Catching Game

This Java code defines a FruitsBasket class with a main method that uses a stack to simulate catching different fruits. The program prompts the user to enter how many fruits they want to catch and then to select each fruit by letter from a list of options to add to the stack, simulating catching multiple fruits in a basket.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import [Link].

*;
public class [Link] {
public static void main(String[] args) {
Scanner fb = new Scanner([Link]);
Stack<String> baskets = new Stack<String>();

String a = "Apple";
String o = "Orange";
String m = "Mango";
String g = "Guava";
char eats;

[Link]("Catch and eat any of these fruits : " +


"('apple' ,'orange', 'mango', 'guava')");
[Link]("How many fruits would you like to catch? : ");
int catcher = [Link]();
[Link]("Choose a fruit to catch. Press A, O, M or G");
for(int x = 1; x <= catcher; x++) {
[Link]("Fruit " + x + " of " + catcher + " : ");
}
}
}

You might also like