Skip to content
Snippets Groups Projects
Commit 86c3056b authored by alec.schmidt's avatar alec.schmidt
Browse files

refactored ContactsController class name because tanguy said so

parent a36c624f
Branches part2
No related tags found
No related merge requests found
package hepia; package hepia;
import hepia.utils.Amis; import hepia.utils.Amis;
import hepia.utils.Contacts; import hepia.utils.ContactController;
import hepia.utils.Professionel; import hepia.utils.Professionel;
public class Main { public class Main {
...@@ -9,7 +9,7 @@ public class Main { ...@@ -9,7 +9,7 @@ public class Main {
// Makeshift code as example // Makeshift code as example
// New contact with random values // New contact "Amis" with random values
Amis test = new Amis(); Amis test = new Amis();
test.setName("Contact1"); test.setName("Contact1");
test.addFirstName("Prenom1"); test.addFirstName("Prenom1");
...@@ -18,17 +18,15 @@ public class Main { ...@@ -18,17 +18,15 @@ public class Main {
test.addMail("test1@address.com"); test.addMail("test1@address.com");
test.addSocial("MrContact"); test.addSocial("MrContact");
test.addPhone("0227865425"); test.addPhone("0227865425");
//test.setJob("Ingénieur Informaticien");
// Let's add the contact to our phone book // Let's add the contact to our phone book
Contacts contacts = new Contacts(); ContactController contacts = new ContactController();
contacts.append(test); contacts.append(test);
// Was it correctly added ? // Was it correctly added ?
contacts.printContacts(); contacts.printContacts();
// Alright // let's add another contact, but this time a "Professionnel"
// let's add another
Professionel test2 = new Professionel(); Professionel test2 = new Professionel();
test2.setName("Contact2"); test2.setName("Contact2");
test2.addFirstName("Prenom1"); test2.addFirstName("Prenom1");
...@@ -55,7 +53,7 @@ public class Main { ...@@ -55,7 +53,7 @@ public class Main {
// contacts.printContacts(); // contacts.printContacts();
// Search a contact based on a string. The method will scan every possible entry and returns a list of contacts containing the string. // Search a contact based on a string. The method will scan every possible entry and returns a list of contacts containing the string.
Contacts search = contacts.search("Prenom1"); ContactController search = contacts.search("Prenom1");
search.printContacts(); search.printContacts();
} }
} }
package hepia.utils; package hepia.utils;
import java.util.Scanner; import java.util.Scanner;
public class Contacts { public class ContactController {
private Contact[] contacts; private Contact[] contacts;
public Contacts() { public ContactController() {
this.contacts = new Contact[0]; this.contacts = new Contact[0];
} }
public Contacts(int size) { public ContactController(int size) {
this.contacts = new Contact[size]; this.contacts = new Contact[size];
} }
...@@ -145,9 +145,9 @@ public class Contacts { ...@@ -145,9 +145,9 @@ public class Contacts {
System.out.println("***END***\n"); System.out.println("***END***\n");
} }
public Contacts search(String s) public ContactController search(String s)
{ {
Contacts result = new Contacts(); ContactController result = new ContactController();
for (Contact contact : this.contacts) { for (Contact contact : this.contacts) {
if (contact instanceof Professionel) if (contact instanceof Professionel)
......
...@@ -16,7 +16,6 @@ public class Famille extends Contact{ ...@@ -16,7 +16,6 @@ public class Famille extends Contact{
this.relation = "Uninitialized"; this.relation = "Uninitialized";
} }
public String toString() { public String toString() {
return "=====================================\n" + return "=====================================\n" +
"Name : " + this.getName() + "\n" + "Name : " + this.getName() + "\n" +
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment