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
No related branches found
No related tags found
No related merge requests found
package hepia;
import hepia.utils.Amis;
import hepia.utils.Contacts;
import hepia.utils.ContactController;
import hepia.utils.Professionel;
public class Main {
......@@ -9,7 +9,7 @@ public class Main {
// Makeshift code as example
// New contact with random values
// New contact "Amis" with random values
Amis test = new Amis();
test.setName("Contact1");
test.addFirstName("Prenom1");
......@@ -18,17 +18,15 @@ public class Main {
test.addMail("test1@address.com");
test.addSocial("MrContact");
test.addPhone("0227865425");
//test.setJob("Ingénieur Informaticien");
// Let's add the contact to our phone book
Contacts contacts = new Contacts();
ContactController contacts = new ContactController();
contacts.append(test);
// Was it correctly added ?
contacts.printContacts();
// Alright
// let's add another
// let's add another contact, but this time a "Professionnel"
Professionel test2 = new Professionel();
test2.setName("Contact2");
test2.addFirstName("Prenom1");
......@@ -55,7 +53,7 @@ public class Main {
// 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.
Contacts search = contacts.search("Prenom1");
ContactController search = contacts.search("Prenom1");
search.printContacts();
}
}
package hepia.utils;
import java.util.Scanner;
public class Contacts {
public class ContactController {
private Contact[] contacts;
public Contacts() {
public ContactController() {
this.contacts = new Contact[0];
}
public Contacts(int size) {
public ContactController(int size) {
this.contacts = new Contact[size];
}
......@@ -145,9 +145,9 @@ public class Contacts {
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) {
if (contact instanceof Professionel)
......
......
......@@ -16,7 +16,6 @@ public class Famille extends Contact{
this.relation = "Uninitialized";
}
public String toString() {
return "=====================================\n" +
"Name : " + this.getName() + "\n" +
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment