Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.concurrent.ArrayBlockingQueue;
- import java.util.jar.Attributes.Name;
- import javax.security.auth.callback.ChoiceCallback;
- import javax.swing.plaf.metal.OceanTheme;
- import java.io.LineNumberInputStream;
- import java.lang.invoke.SwitchPoint;
- import java.util.*;
- public class Main {
- public List<Student> listaStudentow = new ArrayList<Student>();
- Scanner czytnik = new Scanner(System.in);
- Student student;
- OperationsOnFiles operacje;
- public static void main(String[] args) {
- /*List<Student> listaOsob = new ArrayList<Student>();
- Student osoba = new Student("Andrzej", "Duda");
- Student osoba2 = new Student("Jan", "Kowalski");
- Student osoba3 = new Student("Janina", "Kowalska");
- listaOsob.add(osoba);
- listaOsob.add(osoba2);
- listaOsob.add(osoba3);
- OperationsOnFiles operacje = new OperationsOnFiles();
- operacje.ZapiszObiekt(listaOsob);
- List<Student>obj = (List<Student>)operacje.OdczytajObiekt();
- for (Student item : obj) {
- System.out.println(item.imie+" "+item.nazwisko+" ");
- System.out.println();
- System.out.println();
- }
- for(int x = 0; x <listaOsob.size(); x++){
- System.out.println(listaOsob.get(x).imie + " "+ listaOsob.get(x).nazwisko+ " "+ listaOsob.get(x));
- }*/
- Main p2 = new Main();
- Student student = new Student();
- p2.PodawanieImieniaStudenta(student);
- System.out.println(student.getImie());
- p2.WybierzOcene(student);
- }
- public void SendValues() {
- Scanner czytnik = new Scanner(System.in);
- String value = czytnik.nextLine();
- switch (value) {
- case "1":
- Student osoba = new Student("Andrzej", "Duda");
- listaStudentow.add(osoba);
- break;
- case "2":
- default:
- break;
- }
- }
- public void WpisywanieStudenta(Student value) {
- System.out.println("Podaj imie studenta");
- PodawanieImieniaStudenta(value);
- System.out.println("Podaj nazwisko studenta");
- PodawanieNazwiskaStudenta(value);
- }
- public void PodawanieImieniaStudenta(Student value) {
- String temp= "0";
- while(!(checkWord(temp))) {
- System.out.println("Mozesz podawać tylko litery");
- temp = czytnik.next();
- }
- value.setImie(temp);
- }
- public void PodawanieNazwiskaStudenta(Student value) {
- String temp= "0";
- while(!(checkWord(temp))) {
- System.out.println("Mozesz podawać tylko litery");
- temp = czytnik.next();
- }
- value.setNazwisko(temp);
- }
- public boolean checkWord(String name) {
- char[] chars = name.toCharArray();
- for (char c : chars) {
- if(!Character.isLetter(c)) {
- return false;
- }
- }
- return true;
- }
- public boolean checkNumbers(String name) {
- char[] chars = name.toCharArray();
- for (char c : chars) {
- if(!Character.isDigit(c)) {
- return false;
- }
- }
- return true;
- }
- public int checkSelect(Student value) {
- String temp = "a";
- while(!(checkNumbers(temp)&&((Integer.parseInt(temp)<=10 && Integer.parseInt(temp)>=1)))) {
- System.out.println("Mozesz podawac tylko cyfry od 1 do 10");
- temp = czytnik.next();
- }
- return Integer.parseInt(temp);
- }
- public void WybierzOcene(Student student) {
- System.out.println("Oceny studenta");
- for(int i = 0; i<student.ocena.length; i++) {
- System.out.println(i+1+": "+student.ocena[i].toString());
- }
- System.out.println("Miejsce w ktorym miejscu miejscu chcesz wprowadzic zmiany od 1-10");
- int b = checkSelect(student);
- System.out.println(b);
- System.out.println("2: 2\n3: 3\n4: 4\n5: 5\n6: 6\n");
- /*
- switch (key) {
- case value:
- break;
- default:
- break;
- }*/
- }
- /* jesli podales liczbe z klawiatury czyli element w ktory ma byc zmieniona wartosc
- *
- */
- /*
- *
- *
- *
- *
- * */
- }
- /*
- * Włacz program wczytaj dane do kolekcji
- * wyswietl menu wyboru
- * 1 dodaj studenta = imie i nazwisko
- * 2 przegladaj liste studentow
- * wybierasz studenta ----->
- * 1 zmiana nazwiska
- * 2 zmiana imienia
- * 3 Edycja ocen
- * 1 wyswietl liste ocen
- * 1 dodaj ocene
- * 2 usun ocene
- * 3 zapisz plik
- * 0 wyjdz z programu
- *
- *
- *
- *
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement