This repository has been archived on 2025-12-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
2024-09-20 14:17:13 +03:00

30 lines
1015 B
Java

import data.Hedgehog;
import java.util.Scanner;
import java.lang.String;
public class Nana {
public static void main(String[] args) {
Scanner Hhog = new Scanner(System.in); // Create a Scanner object
System.out.println("Give a name to the hedgehog:");
String hog = Hhog.nextLine(); // Read user input
Hedgehog hedgehog = new Hedgehog(hog);
System.out.println(hedgehog.speak()); // output user input
boolean exit = false;
while (!exit) {
System.out.println("What should the hedgehog say?");
String hoggie = Hhog.nextLine();
try {
int input = Integer.parseInt(hoggie);
System.out.println(hedgehog.speakInt(input));
} catch (NumberFormatException ex) {
if ("exit".equals(hoggie)) {
exit = true;
} else {
System.out.println(hedgehog.speakString(hoggie));
}
}
}
}
}