fork download
  1. package principal;
  2.  
  3. import java.util.Scanner;
  4.  
  5. /**
  6.  *
  7.  * @author MiguelAngel
  8.  */
  9. public class Clinic {
  10.  
  11. static private Integer comptaCode = 1; //El proper code a assignar
  12. private Integer code;
  13. private String name;
  14. private String address;
  15. private Doctor[] doctors = new Doctor[10];
  16. private Integer comptaDoctors = 0;
  17. private Nurse[] nurses = new Nurse[100];
  18. private Integer comptaNurses = 0;
  19. private Patient[] patients = new Patient[20];
  20. private Integer comptaPatients = 0;
  21. private Department[] departments = new Department[10];
  22. private Integer comptaDepartments = 0;
  23. private Track[] tracks = new Track[100];
  24. private Integer comptaTracks = 0;
  25.  
  26. /*
  27.   TODO Constructor
  28.   Paràmetres: nom i adreça
  29.   Accions:
  30.   - actualitzar les propietats que ens han passat per paràmetre
  31.   - assignar al codi el comptaCodi actual i incrementar el comptaCodi en 1
  32.   */
  33. public Clinic(String name, String address) {
  34.  
  35. }
  36.  
  37. /*
  38.   TODO Mètodes accessors
  39.   */
  40. public static Clinic addClinic() {
  41. /*
  42.   TODO
  43.   Paràmetres: sense
  44.   Accions:
  45.   - demanar les dades per consola per crear una nova clínica (són les dades simples que demana el constructor)
  46.   Retorneu: la clínica creada
  47.  
  48.   */
  49. }
  50.  
  51. public void updateClinic() {
  52. /*
  53.   TODO
  54.   Paràmetres: sense
  55.   Accions:
  56.   - demanar les dades simples (no taules) per consola i modifiqueu la propietat
  57.   Nota: penseu que estem modificant l'objecte actual ...
  58.   Retorneu: no hi ha retorn
  59.   */
  60. }
  61.  
  62. public void showClinic() {
  63. System.out.println("\nLes dades de la clínica amb codi " + this.getCode() + " són:");
  64. System.out.println("\nNom:" + this.getName());
  65. System.out.println("\nAddreça:" + this.getAddress());
  66. }
  67.  
  68. /*
  69.   Doctors
  70.   */
  71. public void addDoctor() {
  72. /*
  73.   TODO
  74.   Paràmetres: sense
  75.   Accions:
  76.   - afegeix un nou doctor a la llista de doctors d'aquesta clínica (l'objecte actual)
  77.   Nota: penseu que el nou doctor és una tasca de la classe Doctor
  78.   Retorneu: no hi ha retorn
  79.   */
  80. }
  81.  
  82. public Integer selectDoctor() {
  83. Scanner teclado = new Scanner(System.in);
  84. System.out.println("\nNif del doctor?:");
  85. String nifSel = teclado.next();
  86. Integer indexSel = -1;
  87. for (int i = 0; i < comptaDoctors; i++) {
  88. if (doctors[i].getNif().equals(nifSel)) {
  89. indexSel = i;
  90. break;
  91. }
  92. }
  93. return indexSel;
  94. }
  95.  
  96. /*
  97.   Nurses
  98.   */
  99. public void addNurse() {
  100. /*
  101.   TODO
  102.   Paràmetres: sense
  103.   Accions:
  104.   - afegeix un nou infermer a la llista d'infermers d'aquesta clínica (l'objecte actual)
  105.   Nota: penseu que el nou infermer és una tasca de la classe Infermer
  106.   Retorneu: no hi ha retorn
  107.   */
  108. }
  109.  
  110. public Integer selectNurse() {
  111. Scanner teclado = new Scanner(System.in);
  112. System.out.println("\nNif de l'infermer?:");
  113. String nifSel = teclado.next();
  114. Integer indexSel = -1;
  115. for (int i = 0; i < comptaNurses; i++) {
  116. if (nurses[i].getNif().equals(nifSel)) {
  117. indexSel = i;
  118. break;
  119. }
  120. }
  121. return indexSel;
  122. }
  123.  
  124. /*
  125.   Patients
  126.   */
  127. public void addPatient() {
  128. /*
  129.   TODO
  130.   Paràmetres: sense
  131.   Accions:
  132.   - afegeix un nou pacient a la llista de pacients d'aquesta clínica (l'objecte actual)
  133.   Nota: penseu que el nou pacient és una tasca de la classe Patient
  134.   Retorneu: no hi ha retorn
  135.   */
  136. }
  137.  
  138. public Integer selectPatient() {
  139. Scanner teclado = new Scanner(System.in);
  140. System.out.println("\nCodi de pacient?:");
  141. String codeSel = teclado.next();
  142. Integer indexSel = -1;
  143. for (int i = 0; i < comptaPatients; i++) {
  144. if (patients[i].getCode().equals(codeSel)) {
  145. indexSel = i;
  146. break;
  147. }
  148. }
  149. return indexSel;
  150. }
  151.  
  152. /*
  153.   Departments
  154.   */
  155. public void addDepartment() {
  156. /*
  157.   TODO
  158.   Paràmetres: sense
  159.   Accions:
  160.   - afegeix un nou departament a la llista de departaments d'aquesta clínica (l'objecte actual)
  161.   Nota: penseu que el nou departament és una tasca de la classe Department
  162.   Retorneu: no hi ha retorn
  163.   */
  164. }
  165.  
  166. public Integer selectDepartment() {
  167. Scanner teclado = new Scanner(System.in);
  168. System.out.println("\nCodi de departament?:");
  169. String codeSel = teclado.next();
  170. Integer indexSel = -1;
  171. for (int i = 0; i < comptaDepartments; i++) {
  172. if (departments[i].getCode().equals(codeSel)) {
  173. indexSel = i;
  174. break;
  175. }
  176. }
  177. return indexSel;
  178. }
  179.  
  180. public void addDoctorDepartment() {
  181. Department departmentsel = null;
  182. Integer indexSelDepartment = this.selectDepartment();
  183. if (indexSelDepartment >= 0) {
  184. departmentsel = this.getDepartments()[indexSelDepartment];
  185. } else {
  186. System.out.println("\nNo existeix aquest departament");
  187. }
  188. Integer indexSel = this.selectDoctor();
  189. if (indexSel >= 0) {
  190. departmentsel.addDoctorDepartment(this.getDoctors()[indexSel]);
  191. } else {
  192. System.out.println("\nNo existeix aquest doctor");
  193. }
  194. }
  195.  
  196. public void addNurseDepartment() {
  197. Department departmentsel = null;
  198. Integer indexSelDepartment = this.selectDepartment();
  199. if (indexSelDepartment >= 0) {
  200. departmentsel = this.getDepartments()[indexSelDepartment];
  201. } else {
  202. System.out.println("\nNo existeix aquest departament");
  203. }
  204. Integer indexSel = this.selectNurse();
  205. if (indexSel >= 0) {
  206. departmentsel.addNurseDepartment(this.getNurses()[indexSel]);
  207. } else {
  208. System.out.println("\nNo existeix aquest infermer");
  209. }
  210. }
  211.  
  212. public void addPatientDepartment() {
  213. Department departmentsel = null;
  214. Integer indexSelDepartment = this.selectDepartment();
  215. if (indexSelDepartment >= 0) {
  216. departmentsel = this.getDepartments()[indexSelDepartment];
  217. } else {
  218. System.out.println("\nNo existeix aquest departament");
  219. }
  220. Integer indexSel = this.selectPatient();
  221. if (indexSel >= 0) {
  222. departmentsel.addPatientDepartment(this.getPatients()[indexSel]);
  223. } else {
  224. System.out.println("\nNo existeix aquest pacient");
  225. }
  226. }
  227.  
  228. public void addTrack() {
  229. /*
  230.   TODO
  231.   Paràmetres: sense
  232.   Accions:
  233.   - afegeix un nou registre (track) a la llista de registres d'aquesta clínica (l'objecte actual)
  234.   Nota: penseu que un nou registre és una tasca de la classe Track
  235.   Retorneu: no hi ha retorn
  236.   */
  237. }
  238.  
  239.  
  240. }
  241.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:9: error: class Clinic is public, should be declared in a file named Clinic.java
public class Clinic {
       ^
Main.java:15: error: cannot find symbol
    private Doctor[] doctors = new Doctor[10];
            ^
  symbol:   class Doctor
  location: class Clinic
Main.java:17: error: cannot find symbol
    private Nurse[] nurses = new Nurse[100];
            ^
  symbol:   class Nurse
  location: class Clinic
Main.java:19: error: cannot find symbol
    private Patient[] patients = new Patient[20];
            ^
  symbol:   class Patient
  location: class Clinic
Main.java:21: error: cannot find symbol
    private Department[] departments = new Department[10];
            ^
  symbol:   class Department
  location: class Clinic
Main.java:23: error: cannot find symbol
    private Track[] tracks = new Track[100];
            ^
  symbol:   class Track
  location: class Clinic
Main.java:15: error: cannot find symbol
    private Doctor[] doctors = new Doctor[10];
                                   ^
  symbol:   class Doctor
  location: class Clinic
Main.java:17: error: cannot find symbol
    private Nurse[] nurses = new Nurse[100];
                                 ^
  symbol:   class Nurse
  location: class Clinic
Main.java:19: error: cannot find symbol
    private Patient[] patients = new Patient[20];
                                     ^
  symbol:   class Patient
  location: class Clinic
Main.java:21: error: cannot find symbol
    private Department[] departments = new Department[10];
                                           ^
  symbol:   class Department
  location: class Clinic
Main.java:23: error: cannot find symbol
    private Track[] tracks = new Track[100];
                                 ^
  symbol:   class Track
  location: class Clinic
Main.java:63: error: cannot find symbol
        System.out.println("\nLes dades de la cl?nica amb codi " + this.getCode() + " s?n:");
                                                                       ^
  symbol: method getCode()
Main.java:64: error: cannot find symbol
        System.out.println("\nNom:" + this.getName());
                                          ^
  symbol: method getName()
Main.java:65: error: cannot find symbol
        System.out.println("\nAddre?a:" + this.getAddress());
                                              ^
  symbol: method getAddress()
Main.java:181: error: cannot find symbol
        Department departmentsel = null;
        ^
  symbol:   class Department
  location: class Clinic
Main.java:184: error: cannot find symbol
            departmentsel = this.getDepartments()[indexSelDepartment];
                                ^
  symbol: method getDepartments()
Main.java:190: error: cannot find symbol
            departmentsel.addDoctorDepartment(this.getDoctors()[indexSel]);
                                                  ^
  symbol: method getDoctors()
Main.java:197: error: cannot find symbol
        Department departmentsel = null;
        ^
  symbol:   class Department
  location: class Clinic
Main.java:200: error: cannot find symbol
            departmentsel = this.getDepartments()[indexSelDepartment];
                                ^
  symbol: method getDepartments()
Main.java:206: error: cannot find symbol
            departmentsel.addNurseDepartment(this.getNurses()[indexSel]);
                                                 ^
  symbol: method getNurses()
Main.java:213: error: cannot find symbol
        Department departmentsel = null;
        ^
  symbol:   class Department
  location: class Clinic
Main.java:216: error: cannot find symbol
            departmentsel = this.getDepartments()[indexSelDepartment];
                                ^
  symbol: method getDepartments()
Main.java:222: error: cannot find symbol
            departmentsel.addPatientDepartment(this.getPatients()[indexSel]);
                                                   ^
  symbol: method getPatients()
23 errors
stdout
Standard output is empty