Skip to content
Snippets Groups Projects
Commit 2faeaac9 authored by Kellian Mirey's avatar Kellian Mirey
Browse files

Updated Input and Main

parent b141ff9f
No related branches found
No related tags found
No related merge requests found
package main; package main;
import java.util.ArrayList;
public class Input { public class Input {
private String input = ""; private String input = "";
private String[] inputRange; private ArrayList<String> inputRange;
public String getInput() { public String getInput() {
return input; return input;
...@@ -12,8 +14,10 @@ public class Input { ...@@ -12,8 +14,10 @@ public class Input {
this.input = input; this.input = input;
} }
public Input(String[] inputRange) { public Input() {
this.inputRange = inputRange; this.inputRange = new ArrayList<>();
this.inputRange.add("q"); //Commande pour quitter
this.inputRange.add("a"); //Commande pour attaquer
} }
public boolean validInput(){ public boolean validInput(){
......
package main; package main;
public class Main{ import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Input input = new Input();
input.setInput(in.nextLine());
Player JoueurEnnemi = new Player("Ennemi");
while (!input.getInput().equals("q")) {
if(!input.validInput()){
System.out.println("Error input invalid");
input.setInput(in.nextLine());
}
if (input.getInput().equals("a")) {
JoueurEnnemi.damage(attack.PUNCH.getDamage());
System.out.println(JoueurEnnemi.getName() + " health : " + JoueurEnnemi.getCurrentHealth());
input.setInput(in.nextLine());
}
}
in.close();
}
} }
\ No newline at end of file
...@@ -45,4 +45,8 @@ public class Player { ...@@ -45,4 +45,8 @@ public class Player {
attackMultiplier = attackMultiplier * 1.2; attackMultiplier = attackMultiplier * 1.2;
} }
public void damage(int damage){
this.currentHealth -= damage;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment