98 lines
3.5 KiB
Java
98 lines
3.5 KiB
Java
import src.Person;
|
|
import src.Country;
|
|
public class Main {
|
|
public static void main(String[] args) {
|
|
Person p = new Person();
|
|
|
|
// Test setters and print results
|
|
try {
|
|
p.setFirstName("John");
|
|
p.setLastName("Doe");
|
|
System.out.println("Full Name: " + p.getFullName());
|
|
} catch (Exception e) {
|
|
System.out.println("Error setting name: " + e.getMessage());
|
|
}
|
|
|
|
try {
|
|
p.updateBirthday("15.04.2000");
|
|
System.out.println("Birthday: " + p.getBirthdayString());
|
|
System.out.println("Age: " + p.getAge());
|
|
} catch (Exception e) {
|
|
System.out.println("Error setting birthday: " + e.getMessage());
|
|
}
|
|
|
|
try {
|
|
System.out.println("Is Adult (USA): " + p.isAdult(Country.US));
|
|
System.out.println("Is Minor (USA): " + p.isMinor(Country.US));
|
|
} catch (Exception e) {
|
|
System.out.println("Error checking age: " + e.getMessage());
|
|
}
|
|
|
|
try {
|
|
p.setEmail("john.doe@example.com");
|
|
System.out.println("Email: " + p.getEmail());
|
|
} catch (Exception e) {
|
|
System.out.println("Error setting email: " + e.getMessage());
|
|
}
|
|
|
|
try {
|
|
p.setPhoneNumber("+1234567890");
|
|
System.out.println("Phone Number: " + p.getPhoneNumber());
|
|
} catch (Exception e) {
|
|
System.out.println("Error setting phone: " + e.getMessage());
|
|
}
|
|
|
|
System.out.println("\nPerson Details:\n" + p + "\n");
|
|
|
|
// Test invalid email
|
|
try {
|
|
p.setEmail("not-an-email");
|
|
} catch (Exception e) {
|
|
System.out.println("Expected email error: " + e.getMessage());
|
|
}
|
|
|
|
// Test invalid phone
|
|
try {
|
|
p.setPhoneNumber("not-a-phone");
|
|
} catch (Exception e) {
|
|
System.out.println("Expected phone error: " + e.getMessage());
|
|
}
|
|
|
|
// Test invalid birthday
|
|
try {
|
|
p.updateBirthday("99.99.9999");
|
|
} catch (Exception e) {
|
|
System.out.println("Expected birthday error: " + e.getMessage());
|
|
}
|
|
|
|
// Play game in Austria
|
|
String state = "survive";
|
|
System.out.println("\nPlaying Russian Roulette in Austria:");
|
|
while (state.equals("survive")) {
|
|
state = p.playGame(Country.AT);
|
|
System.out.println("Result: " + state + ", Alive: " + p.isAlive());
|
|
if (!p.isAlive()) {
|
|
System.out.println("Time of Death: " + p.getTimeOfDeath());
|
|
System.out.println("Dead Since: " + p.getDeadSince());
|
|
}
|
|
}
|
|
|
|
System.out.println("\nFinal Person Details after Austria:\n" + p + "\n");
|
|
|
|
// Reset for Russia game
|
|
Person p2 = new Person("Jane", "Roe", "01.01.1995", "jane.roe@example.com", "+1987654321");
|
|
System.out.println("\nNew Person for Russia game:\n" + p2 + "\n");
|
|
state = "survive";
|
|
System.out.println("Playing Russian Roulette in Russia:");
|
|
while (state.equals("survive")) {
|
|
state = p2.playGame(Country.RU);
|
|
System.out.println("Result: " + state + ", Alive: " + p2.isAlive());
|
|
if (!p2.isAlive()) {
|
|
System.out.println("Time of Death: " + p2.getTimeOfDeath());
|
|
System.out.println("Dead Since: " + p2.getDeadSince());
|
|
}
|
|
}
|
|
System.out.println("\nFinal Person Details after Russia:\n" + p2 + "\n");
|
|
}
|
|
}
|