Advertisement
Morogn93

Baza

Apr 3rd, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.22 KB | None | 0 0
  1. import java.util.concurrent.ArrayBlockingQueue;
  2. import java.util.jar.Attributes.Name;
  3.  
  4. import javax.security.auth.callback.ChoiceCallback;
  5. import javax.swing.plaf.metal.OceanTheme;
  6.  
  7. import java.io.LineNumberInputStream;
  8. import java.lang.invoke.SwitchPoint;
  9. import java.util.*;
  10. public class Main {
  11.    
  12.     public List<Student> listaStudentow = new ArrayList<Student>();
  13.     Scanner czytnik = new Scanner(System.in);
  14.     Student student;
  15.     OperationsOnFiles operacje;
  16.    
  17.     public static void main(String[] args) {
  18.        
  19.         /*List<Student> listaOsob = new ArrayList<Student>();
  20.         Student osoba = new Student("Andrzej", "Duda");
  21.         Student osoba2 = new Student("Jan", "Kowalski");
  22.         Student osoba3 = new Student("Janina", "Kowalska");
  23.        
  24.         listaOsob.add(osoba);
  25.         listaOsob.add(osoba2);
  26.         listaOsob.add(osoba3);
  27.        
  28.         OperationsOnFiles operacje = new OperationsOnFiles();
  29.  
  30.         operacje.ZapiszObiekt(listaOsob);
  31.        
  32.         List<Student>obj =  (List<Student>)operacje.OdczytajObiekt();
  33.        
  34.         for (Student item : obj) {
  35.            
  36.             System.out.println(item.imie+" "+item.nazwisko+" ");
  37.             System.out.println();
  38.             System.out.println();
  39.         }
  40.        
  41.         for(int x = 0; x <listaOsob.size(); x++){
  42.             System.out.println(listaOsob.get(x).imie + " "+ listaOsob.get(x).nazwisko+ " "+ listaOsob.get(x));
  43.         }*/
  44.         Main p2 = new Main();
  45.        
  46.         Student student = new Student();
  47.        
  48.         p2.PodawanieImieniaStudenta(student);
  49.         System.out.println(student.getImie());
  50.         p2.WybierzOcene(student);
  51.        
  52.        
  53.     }  
  54.     public void SendValues() {     
  55.        
  56.         Scanner czytnik = new Scanner(System.in);
  57.         String value =  czytnik.nextLine();
  58.         switch (value) {
  59.         case "1":
  60.             Student osoba = new Student("Andrzej", "Duda");
  61.             listaStudentow.add(osoba);
  62.             break;
  63.         case "2":
  64.            
  65.         default:
  66.             break;
  67.         }  
  68.     }
  69.    
  70.     public void WpisywanieStudenta(Student value) {
  71.         System.out.println("Podaj imie studenta");
  72.         PodawanieImieniaStudenta(value);
  73.         System.out.println("Podaj nazwisko studenta");
  74.         PodawanieNazwiskaStudenta(value);
  75.     }
  76.     public void PodawanieImieniaStudenta(Student value) {
  77.         String temp= "0";
  78.         while(!(checkWord(temp))) {
  79.             System.out.println("Mozesz podawać tylko litery");
  80.             temp = czytnik.next();
  81.         }
  82.         value.setImie(temp);
  83.     }
  84.     public void PodawanieNazwiskaStudenta(Student value) {
  85.         String temp= "0";
  86.         while(!(checkWord(temp))) {
  87.             System.out.println("Mozesz podawać tylko litery");
  88.             temp = czytnik.next();
  89.         }
  90.         value.setNazwisko(temp);
  91.     }
  92.     public boolean checkWord(String name) {
  93.         char[] chars = name.toCharArray();
  94.         for (char c : chars) {
  95.             if(!Character.isLetter(c)) {
  96.                 return false;
  97.             }
  98.         }
  99.         return true;
  100.     }
  101.     public boolean checkNumbers(String name) {
  102.         char[] chars = name.toCharArray();     
  103.         for (char c : chars) {
  104.             if(!Character.isDigit(c)) {
  105.                 return false;
  106.             }
  107.         }
  108.         return true;
  109.     }
  110.    
  111.     public int checkSelect(Student value) {
  112.         String temp = "a";
  113.         while(!(checkNumbers(temp)&&((Integer.parseInt(temp)<=10 && Integer.parseInt(temp)>=1)))) {
  114.             System.out.println("Mozesz podawac tylko cyfry od 1 do 10");
  115.             temp = czytnik.next();
  116.         }
  117.        
  118.         return Integer.parseInt(temp);
  119.     }
  120.    
  121.    
  122.     public void WybierzOcene(Student student) {
  123.         System.out.println("Oceny studenta");
  124.         for(int i = 0; i<student.ocena.length; i++) {
  125.             System.out.println(i+1+": "+student.ocena[i].toString());
  126.         }      
  127.         System.out.println("Miejsce w ktorym miejscu miejscu chcesz wprowadzic zmiany od 1-10");
  128.        
  129.         int b = checkSelect(student);
  130.         System.out.println(b);
  131.         System.out.println("2: 2\n3: 3\n4: 4\n5: 5\n6: 6\n");
  132.        
  133.         /*
  134.         switch (key) {
  135.         case value:
  136.            
  137.             break;
  138.  
  139.         default:
  140.             break;
  141.         }*/
  142.     }
  143.    
  144.    
  145.    
  146.    
  147.    
  148.    
  149.    
  150.     /* jesli podales liczbe z klawiatury czyli element w ktory ma byc zmieniona wartosc
  151.      *
  152.      */
  153.    
  154.    
  155. /*
  156.  *
  157.  *
  158.  *
  159.  *
  160.  * */  
  161.    
  162.    
  163.    
  164.    
  165. }
  166.  
  167.  
  168. /*
  169.  * Włacz program wczytaj dane do kolekcji
  170.  * wyswietl menu wyboru
  171.  *  1 dodaj studenta = imie i nazwisko
  172.  *  2 przegladaj liste studentow  
  173.  *      wybierasz studenta ----->
  174.  *          1 zmiana nazwiska
  175.  *          2 zmiana imienia
  176.  *          3 Edycja ocen
  177.  *              1 wyswietl liste ocen
  178.  *                  1 dodaj ocene
  179.  *                  2 usun ocene   
  180.  *  3 zapisz plik              
  181.  *  0 wyjdz z programu
  182.  *
  183.  *
  184.  *
  185.  *
  186.  */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement