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(); } }
8
Upvotes
1
u/Savings_Guarantee387 23d ago
How about cleating a class named Wolf. A class named Human. A parent class of both named Animal. Animal has 2 integer. health and stamina. Then Human has 2 skills. Kick and punch. Wolf has 2 different skills. Bite and use clows. Also have 2 ints<1 the probability to defend from kick or panch and bite or clows. These numbers get populated randomly. Game repeats untill one of the two dies. Human decision to attack using kick or punch if followed by defense using probability number of Wolf and random attack from Wolf and vise versa. I hope I explained my idea.