Clinica - AlbertProfe/Java_AppWeb_Spring_2021 GitHub Wiki

Clinica

The first step to creating our exercise. Just 5 classes:

  1. Clinica.java
  2. MainApplication.java
  3. MyDate.java
  4. Person.java
  5. Test.java

Test Class got two static methods to test: testObjects and testConstructorMethod

public static void testObjects()

let's create and test some objects Person and Clinica and add Person Jose to Clinica as a Member

public static void testConstructorMethod()

let's create and test some objects Person with the same ORDER arguments which may cause trouble at constructor so we will create two methods which will call the constructor and return and Person object so: call method > method > call constructor > create object > method return object

Clinica

we create Test class to simplify MainApp:

MainApplication Class

Test Class

Clinica

and Person:

Person0

and how we solve overloading Constructor confusing call, with a builder pattern:

thanks to class Person we may create an object called toni (or laura) with a static method that calls the REAL constructor which creates the REAL object (the static method just makes the call) without age or weight (confusing parameters due to the order at parameters list), so we may create two objects, one with age and another with weight.

Constructor

watch out on toni object the second parameter: 18 is an int age

watch out on laura object the second parameter: 18 is NOT an int age, it is an int weight

Person toni = Person.personConstructorAge("Toni Lopez", 18, 1,1,1980);

Person laura = Person.personConstructorWeigth("Laura Gasol", 60, 1,7,1992);

Constructor_watch