Skip to content

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenKangg committed Apr 7, 2024
1 parent 8a51d8e commit e09370a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
20 changes: 9 additions & 11 deletions src/main/java/seedu/omnitravel/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import java.time.LocalDate;
import java.util.logging.Logger;

import static seedu.omnitravel.errorhandlers.CheckParameters.isNumeric;

public class Parser {

private static Logger logger = Logger.getLogger("ParserLogger");
Expand Down Expand Up @@ -151,7 +149,7 @@ public static void addCommand(String line, TravelActivityList list) throws OmniE
* @throws OmniException if command.length != 2 && command[1] is not numeric
*/
public static void deleteCommand(String[] command, TravelActivityList list) throws OmniException {
if (command.length == 2 && isNumeric(command[1])){
if (command.length == 2 && CheckParameters.isNumeric(command[1])){
int listNumber = Integer.parseInt(command[1]);
list.removeTravelActivity(listNumber);
} else {
Expand All @@ -167,7 +165,7 @@ public static void deleteCommand(String[] command, TravelActivityList list) thro
* @throws OmniException if command.length != 2 && command[1] is not numeric
*/
public static void checkCommand(String[] command, TravelActivityList list) throws OmniException {
if (command.length == 2 && isNumeric(command[1])){
if (command.length == 2 && CheckParameters.isNumeric(command[1])){
int listNumber = Integer.parseInt(command[1]);
list.checkTravelActivity(listNumber);
} else {
Expand All @@ -183,7 +181,7 @@ public static void checkCommand(String[] command, TravelActivityList list) throw
* @throws OmniException if command.length != 2 && command[1] is not numeric
*/
public static void uncheckCommand(String[] command, TravelActivityList list) throws OmniException {
if (command.length == 2 && isNumeric(command[1])){
if (command.length == 2 && CheckParameters.isNumeric(command[1])){
int listNumber = Integer.parseInt(command[1]);

list.uncheckTravelActivity(listNumber);
Expand All @@ -202,7 +200,7 @@ public static void uncheckCommand(String[] command, TravelActivityList list) thr
*/
public static void tagCommand(String line, TravelActivityList list) throws OmniException {
String[] command = line.split(" ");
if (command.length >= 3 && isNumeric(command[1])){
if (command.length >= 3 && CheckParameters.isNumeric(command[1])){
String index = command[1];
String[] tagSplit = line.split(index);
String tag = tagSplit[1].trim();
Expand All @@ -223,7 +221,7 @@ public static void tagCommand(String line, TravelActivityList list) throws OmniE
* @throws OmniException if command.length != 2 && command[1] is not numeric
*/
public static void removeTagCommand(String[] command, TravelActivityList list) throws OmniException {
if (command.length == 2 && isNumeric(command[1])) {
if (command.length == 2 && CheckParameters.isNumeric(command[1])) {
int listNumber = Integer.parseInt(command[1]);
list.removeTag(listNumber);
} else {
Expand Down Expand Up @@ -308,7 +306,7 @@ public static void findCommand(String line, TravelActivityList list) throws Omni
*/
public static void expenseCommand(String line, TravelActivityList list) throws OmniException {
String[] command = line.split(" ");
if (command.length == 3 && isNumeric(command[1])){
if (command.length == 3 && CheckParameters.isNumeric(command[1])){
int listNumber = Integer.parseInt(command[1]);
String expense = command[2];
list.expenseActivity(listNumber, expense);
Expand All @@ -327,7 +325,7 @@ public static void expenseCommand(String line, TravelActivityList list) throws O
* @throws OmniException if command.length != 2 && command[1] is not numeric
*/
public static void removeExpenseCommand(String[] command, TravelActivityList list) throws OmniException {
if (command.length == 2 && isNumeric(command[1])) {
if (command.length == 2 && CheckParameters.isNumeric(command[1])) {
int listNumber = Integer.parseInt(command[1]);
list.removeExpense(listNumber);
} else {
Expand Down Expand Up @@ -369,7 +367,7 @@ public static void totalExpenseCommand(String line, TravelActivityList list) thr
*/
public static void locationCommand(String line, TravelActivityList list) throws OmniException {
String[] command = line.split(" ");
if (command.length >= 3 && isNumeric(command[1])){
if (command.length >= 3 && CheckParameters.isNumeric(command[1])){
String index = command[1];
String[] locationSplit = line.split(index);
String location = locationSplit[1].trim();
Expand All @@ -390,7 +388,7 @@ public static void locationCommand(String line, TravelActivityList list) throws
* @throws OmniException if command.length != 2 && command[1] is not numeric
*/
public static void removeLocationCommand(String[] command, TravelActivityList list) throws OmniException {
if (command.length == 2 && isNumeric(command[1])) {
if (command.length == 2 && CheckParameters.isNumeric(command[1])) {
int listNumber = Integer.parseInt(command[1]);
list.removeLocation(listNumber);
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/seedu/omnitravel/OmniTravelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,13 @@ public void testListTags() throws OmniException {

// Testcases without tags
list.addTravelActivity(new Accommodation("Airbnb",
LocalDate.parse("2012-12-12"), "2hours", "", ""));
LocalDate.parse("2012-12-12"), "2hours", "", "", ""));
list.addTravelActivity(new Food("Takoyaki",
LocalDate.parse("2012-12-12"), "2hours", "", ""));
LocalDate.parse("2012-12-12"), "2hours", "", "", ""));
list.addTravelActivity(new Landmark("Pyramid",
LocalDate.parse("2012-12-12"), "2hours", "", ""));
LocalDate.parse("2012-12-12"), "2hours", "", "", ""));
list.addTravelActivity(new TravelActivity("Go home",
LocalDate.parse("2012-12-12"), "2hours", "", ""));
LocalDate.parse("2012-12-12"), "2hours", "", "", ""));

list.listTags();
String expectedOutput = "1. campus stay" + System.lineSeparator()
Expand Down

0 comments on commit e09370a

Please sign in to comment.