forked from nus-cs2103-AY2324S2/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from H4mes/branch-AddOutlets
Implement Outlet article attribute as class
- Loading branch information
Showing
14 changed files
with
238 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package seedu.address.model.article; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.commons.util.AppUtil.checkArgument; | ||
|
||
/** | ||
* Represents the news outlet an Article is published by | ||
*/ | ||
public class Outlet { | ||
public static final String MESSAGE_CONSTRAINTS = "Outlet names should be alphanumeric"; | ||
public static final String VALIDATION_REGEX = "[\\p{Alnum} ]+"; | ||
|
||
public final String outletName; | ||
|
||
|
||
/** | ||
* Constructs a {@code outletName}. | ||
* | ||
* @param outletName A valid outlet name. | ||
*/ | ||
public Outlet(String outletName) { | ||
requireNonNull(outletName); | ||
checkArgument(isValidOutletName(outletName), MESSAGE_CONSTRAINTS); | ||
this.outletName = outletName; | ||
} | ||
|
||
/** | ||
* Returns true if a given string is a valid outlet name. | ||
*/ | ||
public static boolean isValidOutletName(String test) { | ||
return test.matches(VALIDATION_REGEX); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) { | ||
return true; | ||
} | ||
|
||
// instanceof handles nulls | ||
if (!(other instanceof Outlet)) { | ||
return false; | ||
} | ||
|
||
Outlet otherOutlet = (Outlet) other; | ||
return outletName.equals(otherOutlet.outletName); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return outletName.hashCode(); | ||
} | ||
|
||
/** | ||
* Format state as text for viewing. | ||
*/ | ||
public String toString() { | ||
return '[' + outletName + ']'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.