Advertisement
Istquai

Untitled

Jul 28th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.78 KB | None | 0 0
  1. /**
  2.  * Created by Istquai on 28.07.2017.
  3.  */
  4. public class Patient {
  5.     private String firstName;
  6.     private String lastName;
  7.     private String pesel;
  8.  
  9.     public String getFirstName() {
  10.         return firstName;
  11.     }
  12.  
  13.     public void setFirstName(String firstName) {
  14.         this.firstName = firstName;
  15.     }
  16.  
  17.     public String getLastName() {
  18.         return lastName;
  19.     }
  20.  
  21.     public void setLastName(String lastName) {
  22.         this.lastName = lastName;
  23.     }
  24.  
  25.     public String getPesel() {
  26.         return pesel;
  27.     }
  28.  
  29.     public void setPesel(String pesel) {
  30.         this.pesel = pesel;
  31.     }
  32.  
  33.     public Patient(String firstName, String lastName, String pesel) {
  34.         this.firstName = firstName;
  35.         this.lastName = lastName;
  36.         this.pesel = pesel;
  37.     }
  38. }
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56. /**
  57.  * Created by Istquai on 28.07.2017.
  58.  */
  59. import java.util.Scanner;
  60.  
  61. public class Hospital {
  62.     Patient[] tab = new Patient[200];
  63.  
  64.  
  65.     public void dopisz() {
  66.         Scanner reader = new Scanner(System.in);
  67.         int i = 0;
  68.         String firstName, lastName, pesel;
  69.  
  70.         System.out.println("Podaj imię: ");
  71.         firstName = reader.nextLine();
  72.         System.out.println("Podaj nazwisko");
  73.         lastName = reader.nextLine();
  74.         System.out.println("Podaj pesel");
  75.         pesel = reader.nextLine();
  76.  
  77.         tab[i] = new Patient(firstName, lastName, pesel);
  78.         i++;
  79.         return;
  80.     }
  81.  
  82.     public void wyswietl() {
  83.         for (Patient tmp : tab) {
  84.             System.out.println(tab);
  85.         }
  86.     }
  87. }
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98. /**
  99.  * Created by Istquai on 28.07.2017.
  100.  */
  101.  
  102.  
  103. import java.util.Scanner;
  104.  
  105. public class HospitalApp {
  106.     public static void main(String[] args) {
  107.         Scanner input = new Scanner(System.in);
  108.         Hospital app = new Hospital();
  109.         int select = 3;
  110.         int licznikDodawania = 0;
  111.  
  112.         while (select != 0) {
  113.             System.out.println("Co chcesz zrobić?");
  114.             System.out.println("0 - wyjście z programu");
  115.             System.out.println("1 - dopisanie pacjenta");
  116.             System.out.println("2 - wyświetlenie listy zapisanych pacjentów");
  117.  
  118.             select = input.nextInt();
  119.             if (select == 1) licznikDodawania++;
  120.             if (licznikDodawania < 11) {
  121.                 switch (select) {
  122.                     case 0:
  123.                         break;
  124.                     case 1:
  125.                         app.dopisz();
  126.                     case 2:
  127.                         app.wyswietl();
  128.                 }
  129.             }
  130.             else {
  131.                 System.out.println("NA DZISIAJ KONIEC ZAPISYWANIA!");
  132.                 System.out.println("");
  133.             }
  134.  
  135.         }
  136.         input.close();
  137.         return;
  138.     }
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement