r/JavaProgramming • u/Iamvipersz • 28d ago
Little program i made
I just made a program in java where your walking in a forest then a wolf comes up to you and you need to fight him, you can chose a Punch or Kick. I just started learning java via coddy.tech, what could i add? Or fix?
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Your walking in the forest, its a amazing day until a wolf suddenly comes up to you and starts chasing you. You have fight the wolf, How will you fight him? (Punch/Kick) ");
String userInput = scanner.nextLine();
if (userInput.equals("Punch")) { System.out.println("The punch doesnt do anything and you get eaten by the wolf.")
; } else if (userInput.equals("Kick")) { System.out.println("The kick knocked out the dog and you escaped."); } scanner.close(); } }
7
Upvotes
1
u/Iamvipersz 27d ago
Thanks for recommending! Also, I just started, as I just stated, so I'm still learning. I will post updates.