Skip to content

Commit

Permalink
Merge branch 'AY2324S1-CS2103T-F08-2:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
LicongHuang authored Oct 25, 2023
2 parents e623822 + 0bab3a7 commit 3b7af27
Show file tree
Hide file tree
Showing 42 changed files with 1,097 additions and 972 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class AddLeadCommand extends Command {

public static final String MESSAGE_SUCCESS = "New lead added: %1$s";

public static final String MESSAGE_DUPLICATE_CLIENT = "This lead already exists in the address book";
public static final String MESSAGE_DUPLICATE_LEAD = "This lead already exists in the address book";

private final Lead toAdd;

Expand All @@ -53,7 +53,7 @@ public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);

if (model.hasPerson(toAdd)) {
throw new CommandException(MESSAGE_DUPLICATE_CLIENT);
throw new CommandException(MESSAGE_DUPLICATE_LEAD);
}

model.addLead(toAdd);
Expand Down
63 changes: 0 additions & 63 deletions src/main/java/seedu/address/logic/parser/AddCommandParser.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import seedu.address.commons.core.LogsCenter;
import seedu.address.logic.commands.AddClientCommand;
import seedu.address.logic.commands.AddCommand;
import seedu.address.logic.commands.AddLeadCommand;
import seedu.address.logic.commands.ClearCommand;
import seedu.address.logic.commands.Command;
Expand Down Expand Up @@ -59,9 +58,6 @@ public Command parseCommand(String userInput) throws ParseException {

switch (commandWord) {

case AddCommand.COMMAND_WORD:
return new AddCommandParser().parse(arguments);

case AddClientCommand.COMMAND_WORD:
return new AddClientCommandParser().parse(arguments);

Expand Down
67 changes: 2 additions & 65 deletions src/main/java/seedu/address/model/AddressBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import seedu.address.model.person.Client;
import seedu.address.model.person.Lead;
import seedu.address.model.person.Person;
import seedu.address.model.person.UniqueClientList;
import seedu.address.model.person.UniqueLeadList;
import seedu.address.model.person.UniquePersonList;

/**
Expand All @@ -20,8 +18,6 @@
public class AddressBook implements ReadOnlyAddressBook {

private final UniquePersonList persons;
private final UniqueClientList clients;
private final UniqueLeadList leads;

/*
* The 'unusual' code block below is a non-static initialization block, sometimes used to avoid duplication
Expand All @@ -32,8 +28,6 @@ public class AddressBook implements ReadOnlyAddressBook {
*/
{
persons = new UniquePersonList();
clients = new UniqueClientList();
leads = new UniqueLeadList();
}

public AddressBook() {}
Expand All @@ -56,31 +50,13 @@ public void setPersons(List<Person> persons) {
this.persons.setPersons(persons);
}

/**
* Replaces the contents of the person list with {@code clients}.
* {@code clients} must not contain duplicate clients, use when loading clients from json.
*/
public void setClients(List<Client> clients) {
this.clients.setClients(clients);
}

/**
* Replaces the contents of the person list with {@code leads}.
* {@code leads} must not contain duplicate leads, use when loading leads from json.
*/
public void setLeads(List<Lead> leads) {
this.leads.setLeads(leads);
}

/**
* Resets the existing data of this {@code AddressBook} with {@code newData}.
*/
public void resetData(ReadOnlyAddressBook newData) {
requireNonNull(newData);

setPersons(newData.getPersonList());
setClients(newData.getClientList());
setLeads(newData.getLeadList());
}

//// person-level operations
Expand All @@ -106,7 +82,6 @@ public void addPerson(Person person) {
* The client must not already exist in the address book.
*/
public void addClient(Client client) {
clients.add(client);
persons.add(client);
}

Expand All @@ -115,7 +90,6 @@ public void addClient(Client client) {
* The lead must not already exist in the address book.
*/
public void addLead(Lead lead) {
leads.add(lead);
persons.add(lead);
}

Expand All @@ -129,16 +103,6 @@ public void setPerson(Person target, Person editedPerson) {
persons.setPerson(target, editedPerson);
}

public void setClient(Client target, Client editedPerson) {
requireNonNull(editedPerson);
clients.setClient(target, editedPerson);
}

public void setLead(Lead target, Lead editedPerson) {
requireNonNull(editedPerson);
leads.setLead(target, editedPerson);
}

/**
* Removes {@code personKey} from this {@code AddressBook}.
* {@code personKey} must exist in the address book.
Expand All @@ -147,24 +111,6 @@ public void removePerson(Person personKey) {
persons.remove(personKey);
}

/**
* Removes {@code clientKey} from this {@code AddressBook}.
* {@code clientKey} must exist in the address book.
*/
public void removeClient(Client clientKey) {
clients.remove(clientKey);
persons.remove(clientKey);
}

/**
* Removes {@code leadKey} from this {@code AddressBook}.
* {@code leadKey} must exist in the address book.
*/
public void removeLead(Lead leadKey) {
leads.remove(leadKey);
persons.remove(leadKey);
}

//// util methods

@Override
Expand All @@ -179,15 +125,6 @@ public ObservableList<Person> getPersonList() {
return persons.asUnmodifiableObservableList();
}

@Override
public ObservableList<Client> getClientList() {
return clients.asUnmodifiableObservableList();
}

@Override
public ObservableList<Lead> getLeadList() {
return leads.asUnmodifiableObservableList();
}

@Override
public boolean equals(Object other) {
Expand All @@ -201,11 +138,11 @@ public boolean equals(Object other) {
}

AddressBook otherAddressBook = (AddressBook) other;
return clients.equals(otherAddressBook.clients) && leads.equals(otherAddressBook.leads);
return persons.equals(otherAddressBook.persons);
}

@Override
public int hashCode() {
return clients.hashCode() + leads.hashCode();
return persons.hashCode();
}
}
7 changes: 0 additions & 7 deletions src/main/java/seedu/address/model/ReadOnlyAddressBook.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package seedu.address.model;

import javafx.collections.ObservableList;
import seedu.address.model.person.Client;
import seedu.address.model.person.Lead;
import seedu.address.model.person.Person;

/**
Expand All @@ -15,9 +13,4 @@ public interface ReadOnlyAddressBook {
* This list will not contain any duplicate persons.
*/
ObservableList<Person> getPersonList();

ObservableList<Client> getClientList();

ObservableList<Lead> getLeadList();

}
6 changes: 2 additions & 4 deletions src/main/java/seedu/address/model/person/Client.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package seedu.address.model.person;

import static seedu.address.commons.util.CollectionUtil.addItemToSet;

import java.util.Set;

import seedu.address.model.tag.Tag;
Expand All @@ -10,13 +8,13 @@
* Represents a Client in the address book.
*/
public class Client extends Person {
public static final String TAG_CLIENT = "Client";
public static final String TYPE_CLIENT = "client";

/**
* Every field must be present and not null.
*/
public Client(Name name, Phone phone, Email email, Address address, Set<Tag> tags) {
super(name, phone, email, address, addItemToSet(tags, new Tag(TAG_CLIENT)));
super(name, phone, email, new Type(TYPE_CLIENT), address, tags);
}

@Override
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/seedu/address/model/person/Lead.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package seedu.address.model.person;

import static seedu.address.commons.util.CollectionUtil.addItemToSet;

import java.util.Set;

import seedu.address.model.tag.Tag;
Expand All @@ -10,13 +8,13 @@
* Represents a Lead in the address book.
*/
public class Lead extends Person {
public static final String TAG_LEAD = "Lead";
public static final String TYPE_LEAD = "lead";

/**
* Every field must be present and not null.
*/
public Lead(Name name, Phone phone, Email email, Address address, Set<Tag> tags) {
super(name, phone, email, address, addItemToSet(tags, new Tag(TAG_LEAD)));
super(name, phone, email, new Type(TYPE_LEAD), address, tags);
}

@Override
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/seedu/address/model/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public abstract class Person {
private final Name name;
private final Phone phone;
private final Email email;
private final Type type;

// Data fields
private final Address address;
Expand All @@ -28,11 +29,12 @@ public abstract class Person {
/**
* Every field must be present and not null.
*/
public Person(Name name, Phone phone, Email email, Address address, Set<Tag> tags) {
public Person(Name name, Phone phone, Email email, Type type, Address address, Set<Tag> tags) {
requireAllNonNull(name, phone, email, address, tags);
this.name = name;
this.phone = phone;
this.email = email;
this.type = type;
this.address = address;
this.tags.addAll(tags);
}
Expand All @@ -49,6 +51,10 @@ public Email getEmail() {
return email;
}

public Type getType() {
return type;
}

public Address getAddress() {
return address;
}
Expand Down Expand Up @@ -93,14 +99,15 @@ public boolean equals(Object other) {
return name.equals(otherPerson.name)
&& phone.equals(otherPerson.phone)
&& email.equals(otherPerson.email)
&& type.equals(otherPerson.type)
&& address.equals(otherPerson.address)
&& tags.equals(otherPerson.tags);
}

@Override
public int hashCode() {
// use this method for custom fields hashing instead of implementing your own
return Objects.hash(name, phone, email, address, tags);
return Objects.hash(name, phone, email, type, address, tags);
}

@Override
Expand All @@ -109,6 +116,7 @@ public String toString() {
.add("name", name)
.add("phone", phone)
.add("email", email)
.add("type", type)
.add("address", address)
.add("tags", tags)
.toString();
Expand Down
Loading

0 comments on commit 3b7af27

Please sign in to comment.