Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- User user;
- String opcija;
- Scanner sc = new Scanner(System.in);
- do {
- do {
- System.out.println("0. Izadjite iz aplikacije");
- System.out.println("1. Ulogujte se");
- System.out.println("2. Vidite rang listu ucenika");
- System.out.println("Unesite redni broj opcije:");
- opcija = sc.nextLine();
- } while (!Objects.equals(opcija, "0") && !Objects.equals(opcija, "1") && !Objects.equals(opcija, "2"));
- if (Objects.equals(opcija, "0")) {
- // Izlazak iz aplikacije
- System.exit(1337);
- } else if (Objects.equals(opcija, "1")) {
- // Log in
- boolean isLogged = false;
- String username, password, pozicija;
- int counter = 0;
- do {
- if (counter == 3) {
- System.out.println("sry bro");
- System.exit(1337);
- }
- System.out.println("Unesite korisnicko ime: ");
- username = sc.nextLine();
- System.out.println("Unesite sifru: ");
- password = sc.nextLine();
- user = User.login(username, password);
- counter++;
- } while (user == null);
- isLogged = true;
- if (Objects.equals(user.getPozicija(), "administrator")){
- // Administrator
- do {
- System.out.println("0. Izlogujte se");
- System.out.println("1. Dodajte takmicara");
- System.out.println("2. Dodajte clana komisije");
- System.out.println("3. Obrisite korisnika");
- System.out.println("Unesite redni broj opcije:");
- opcija = sc.nextLine();
- if (Objects.equals(opcija, "0")){
- // log out
- isLogged = false;
- } else if (Objects.equals(opcija, "1")){
- // Add takmicar
- Takmicar newTakmicar = new Takmicar();
- System.out.println("Unesite ime takmicara:");
- newTakmicar.setIme(sc.nextLine());
- System.out.println("Unesite prezime takmicara:");
- newTakmicar.setPrezime(sc.nextLine());
- System.out.println("Unesite username takmicara:");
- newTakmicar.setUsername(sc.nextLine());
- System.out.println("Unesite sifru takmicara:");
- newTakmicar.setPassword(sc.nextLine());
- newTakmicar.addUserToDatabase();
- } else if (Objects.equals(opcija, "2")){
- // Add clan komisije
- Komisija newKomisija = new Komisija();
- System.out.println("Unesite ime clana komisije:");
- newKomisija.setIme(sc.nextLine());
- System.out.println("Unesite prezime clana komisije:");
- newKomisija.setPrezime(sc.nextLine());
- System.out.println("Unesite username clana komisije:");
- newKomisija.setUsername(sc.nextLine());
- System.out.println("Unesite sifru clana komisije:");
- newKomisija.setPassword(sc.nextLine());
- newKomisija.addUserToDatabase();
- } else if (Objects.equals(opcija, "3")){
- // Remove user
- System.out.println("Unesite username korisnika kojeg zelite da obrisete:");
- //System.out.println(user);
- ((Administrator) user).removeUserFromDatabase(sc.nextLine());
- }
- } while (!Objects.equals(opcija, "0") && !Objects.equals(opcija, "1") && !Objects.equals(opcija, "2") && !Objects.equals(opcija, "3") || isLogged);
- } else if (Objects.equals(user.getPozicija(), "komisija")){
- // Komisija
- do {
- System.out.println("0. Odjavite se");
- System.out.println("1. Prikazi spisak radova");
- System.out.println("2. Oceni rad");
- System.out.println("Unesite redni broj opcije:");
- opcija = sc.nextLine();
- if (Objects.equals(opcija, "0")){
- // Log out
- isLogged = false;
- } else if (Objects.equals(opcija, "1")){
- // Prikazi spisak radova
- File file = new File("predatiRadovi");
- if (file.exists()){
- String[] listaRadova = file.list();
- for (String rad : listaRadova) {
- System.out.println(rad);
- }
- }
- } else if (Objects.equals(opcija, "2")){
- // Oceni rad
- File file = new File("predatiRadovi");
- if (file.exists()){
- int brojRadova = 0;
- int izabraniRad = 0;
- String[] listaRadova = file.list();
- for (String rad : listaRadova) {
- brojRadova++;
- System.out.println(brojRadova + ". " + rad);
- }
- if (brojRadova != 0){
- do {
- System.out.println("Unesite redni broj rada koji zelite da ocenite:");
- try{
- izabraniRad = sc.nextInt();
- } catch (InputMismatchException e){
- sc.nextLine();
- }
- } while (izabraniRad < 1 || izabraniRad > brojRadova);
- try {
- System.out.println("Sadrzaj rada:\n");
- ArrayList<String> lines = (ArrayList<String>) Files.readAllLines(Paths.get("predatiRadovi" + File.separator + listaRadova[izabraniRad-1]), Charset.forName("UTF-8"));
- for (String line : lines){
- System.out.println(line);
- }
- int ocena1 = 0, ocena2 = 0, ocena3 = 0;
- do {
- try {
- System.out.println("Unesite ocenu za kvalitet koda:");
- ocena1 = sc.nextInt();
- } catch (InputMismatchException e){
- sc.nextLine();
- }
- } while (ocena1 < 1 || ocena1 > 10);
- do{
- try {
- System.out.println("Unesite ocenu za tacnost koda:");
- ocena2 = sc.nextInt();
- } catch (InputMismatchException e){
- sc.nextLine();
- }
- } while (ocena2 < 1 || ocena2 > 10);
- do{
- try {
- System.out.println("Unesite ocenu opsti utisak: ");
- ocena3 = sc.nextInt();
- } catch (InputMismatchException e){
- sc.nextLine();
- }
- } while (ocena3 < 1 || ocena3 > 10);
- ((Komisija) user).oceniRad(listaRadova[izabraniRad-1].split("\\.")[0], "predatiRadovi" + File.separator + listaRadova[izabraniRad-1], ocena1, ocena2, ocena3);
- Files.move(Paths.get("predatiRadovi" + File.separator + listaRadova[izabraniRad-1]), Paths.get("pregledaniRadovi" + File.separator + listaRadova[izabraniRad-1]));
- } catch (IOException e) {
- System.out.println("Doslo je do greske prilikom pomeranja fajla. Da li postoji problem sa permisijama?");
- e.printStackTrace();
- }
- } else {
- System.out.println("Svi radovi su ocenjeni.");
- }
- }
- }
- } while (!Objects.equals(opcija, "0") && !Objects.equals(opcija, "1") && !Objects.equals(opcija, "2") || isLogged);
- } else if (Objects.equals(user.getPozicija(), "takmicar")){
- // Takmicar
- do {
- System.out.println("0. Odjavite se");
- System.out.println("1. Predaj rad");
- System.out.println("2. Pogledaj status rada");
- System.out.println("Unesite redni broj opcije:");
- opcija = sc.nextLine();
- if (Objects.equals(opcija, "0")) {
- // Log out
- isLogged = false;
- } else if (Objects.equals(opcija, "1")) {
- // Predaja rada
- System.out.println("Unesite absolutnu putanju rada: ");
- String putanja = sc.nextLine();
- ((Takmicar) user).predajRad(username, putanja);
- } else if (Objects.equals(opcija, "2")) {
- // Status rada
- ((Takmicar) user).statusRada(username);
- }
- } while (!Objects.equals(opcija, "0") && !Objects.equals(opcija, "1") && !Objects.equals(opcija, "2") || isLogged);
- }
- } else {
- User.rangLista();
- }
- } while (true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement