Clinica3 - AlbertProfe/Java_AppWeb_Spring_2021 GitHub Wiki

Clinica3

We finish this exercise refactoring (just a while and a menu) MainApp to resemble MVC and adding the last feature: test clinic.

public static void testClinicaMembersArray()

let's create and test finally clinic and members so members will be person, student, teacher, employee and doctor

We add a new static method to test: testClinicaMembersArray

  1. Clinica.java
  2. Course.java
  3. Doctor.java
  4. Employee.java
  5. MainApplication.java
  6. MyDate.java
  7. Person.java
  8. Student.java
  9. Teacher.java
  10. Test.java
  11. Utilities.java

Clinica2

MainApp with long-while

        `while (true) {`
    	
    	`//In MVR pattern design this lines are considered the View tier`
    	`//so we collect some data and show results to user`
    	`System.out.println("\nChoose one option ...");`
    	`System.out.println("0 - Quit");`
    	`System.out.println("1 - test Objects Person ");`
    	`System.out.println("2 - test Constructor Method Person");`
    	`System.out.println("3 - test Object Student");`
    	`System.out.println("4 - test Utilities Inherence Class Person");`
    	`System.out.println("5 - test Objects Course: Teacher/Student");`
    	`System.out.println("6 - test Clinica Members Array");`
    	
    	`System.out.println("\noption? ");`
        `String command = reader.nextLine();`
        `Utilities.clear();`

        
        `//In MVR pattern design this lines are considered the Controller tier`
    	`//so we collect the requests at front controller and deliver them to`
        `//where they will be processed, in our case static methods at Test Class`
        `if (command.equals("0")) {`
            `break;`
        `} else if (command.equals("1")) {`
        	`Test.testObjectsPerson();`
        `} else if (command.equals("2")) {`
        	`Test.testConstructorMethod();`
        `} else if (command.equals("3")) {`
        	`Test.testObjectsStudent();`
        `} else if (command.equals("4")) {`
        	`Test.testUtilitiesInherence();`
        `} else if (command.equals("5")) {`
        	`Test.testObjectsCourse();`
        `} else if (command.equals("6")) {`
        	`Test.testClinicaMembersArray();`
        `} else {`
        	`System.out.println("Unknown command!");`
        `}`
    `}`

MainApplication with long-while and without static methods

MainApp with short-while and static methods

But one last change in MainApp to resemble MVC:

static main working as general operations managment MainAppFinalChange

static menuView working as a View at MVC View

static controller working as a Controller at MVC Controller