add files

This commit is contained in:
2026-04-14 20:07:23 +03:30
commit 83df1ab515
6 changed files with 728 additions and 0 deletions
+118
View File
@@ -0,0 +1,118 @@
import java.util.*;
public class finalproject {
public static void main(String[] args) {
while (true) {
asli();
}
}
public static void asli() {
Scanner input = new Scanner(System.in);
boolean exit = true;
System.out.println(
"\nlooser game\n- - - - - - - - - - - - \nEnter your choice : \n1. Login\n2. Signup\n3. Exit ");
int choice = input.nextInt();
input.nextLine();
if (choice == 1) {
while (true) {
System.out.println("please enter your name : ");
String name = input.nextLine();
System.out.println("pleade enter your password : ");
String password = input.nextLine();
String a = AuthService.getObject().login(name, password);
if (a.equals("Invalid Username or Password!")) {
System.out.println("1. try again ");
System.out.println("2.back");
int choice2 = input.nextInt();
input.nextLine();
if (choice2 == 1) {
continue;
} else if (choice2 == 2) {
return;
} else {
System.out.println("Unvalid input!");
return;
}
} else {
while (exit) {
exit = startmenue();
}
}
return;
}
} else if (choice == 2) {
System.out.println("pleade enter your name : ");
String name = input.nextLine();
System.out.println("pleade enter your password : ");
String password = input.nextLine();
AuthService.getObject().signup(name, password);
} else if (choice == 3) {
System.exit(0);
} else {
System.out.println("Unvalid input!");
}
}
public static boolean startmenue() {
Scanner input = new Scanner(System.in);
System.out.println(
"\nEnter your choice : \n1. Start game\n2. Show leaderboard\n3. Add new word\n4. Exit\n5. change password");
int choice3 = input.nextInt();
input.nextLine();
if (choice3 == 1) {
Game game = new Game();
game.startGame(AuthService.getObject().getlastlogin());
return (true);
} else if (choice3 == 2) {
Leaderboard.getObject().display();
return (true);
} else if (choice3 == 3) {
System.out.println("please enter your word : ");
String newword = input.nextLine();
WordBank.getObject().addWord(newword);
System.out.println();
System.out.println("Word added successfully!");
return (true);
} else if (choice3 == 4) {
return (false);
} else if (choice3 == 5) {
System.out.println("plaese enter your old password: ");
String oldpass = input.nextLine();
System.out.println("plaese enter new password: ");
String newpass = input.nextLine();
User a = AuthService.getObject().getlastlogin();
a.changePassword(oldpass, newpass);
return (true);
} else {
System.out.println("Unvalid input!");
return (true);
}
}
}