Skip to content

Commit

Permalink
Merge pull request nus-cs2113-AY2324S2#46 from samuelory/Samuel-Check…
Browse files Browse the repository at this point in the history
…stylemain

Fixed check style violations
  • Loading branch information
IanFH authored Mar 20, 2024
2 parents f1698de + 207d18a commit 9088e59
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/main/java/florizz/command/AddFlowerCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import florizz.objects.Flower;

import java.util.ArrayList;
import java.util.concurrent.Flow;


public class AddFlowerCommand extends Command{
private String flowerName;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/florizz/command/HelpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ public boolean execute(ArrayList<Bouquet> bouquetList, Ui ui) {
ui.printHelpMessage();
return true;
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/florizz/core/OccasionDictionary.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
public class OccasionDictionary {
private static HashSet<String> uniqueOccasions = new HashSet<>();

public static void add(String Occasion) {
uniqueOccasions.add(Occasion);
public static void add(String occasion) {
uniqueOccasions.add(occasion);
}

public static void startup() {
Expand Down
26 changes: 20 additions & 6 deletions src/main/java/florizz/core/Parser.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
package florizz.core;

import florizz.command.*;
import florizz.command.Command;
import florizz.command.AddBouquetCommand;
import florizz.command.AddFlowerCommand;
import florizz.command.DeleteBouquetCommand;
import florizz.command.ExitCommand;
import florizz.command.FlowerCommand;
import florizz.command.InfoCommand;
import florizz.command.ListBouquetCommand;
import florizz.command.ListOccasionCommand;
import florizz.command.RemoveFlowerCommand;
import florizz.command.HelpCommand;
import florizz.objects.Bouquet;

public class Parser {
Expand Down Expand Up @@ -30,7 +40,7 @@ public static Command parse (String input) throws FlorizzException{
case ("flower"):
return handleFlowerCommand(input);
case ("info"):
return handleInfoCommand(input);
return handleInfoCommand(input);
case ("occasion"):
return new ListOccasionCommand();
case ("add"):
Expand Down Expand Up @@ -99,11 +109,13 @@ private static FlowerCommand handleFlowerCommand(String input) {

private static AddFlowerCommand handleAddFlower(String argument) throws FlorizzException {
if (argument == null) {
throw new FlorizzException("No argument detected! Please use the correct format of 'add <flowerName> /q <quantity> /to <bouquetName>");
throw new FlorizzException("No argument detected! " +
"Please use the correct format of 'add <flowerName> /q <quantity> /to <bouquetName>");
}

if (!argument.matches(ADD_FLOWER_REGEX)) {
throw new FlorizzException("Incorrect format detected! Please use the correct format of 'add <flowerName> /q <quantity> /to <bouquetName>");
throw new FlorizzException("Incorrect format detected! " +
"Please use the correct format of 'add <flowerName> /q <quantity> /to <bouquetName>");
}

// [WARNING] might need to check for extra slash k
Expand All @@ -122,11 +134,13 @@ private static AddFlowerCommand handleAddFlower(String argument) throws FlorizzE

private static RemoveFlowerCommand handleRemoveFlower(String argument) throws FlorizzException {
if (argument == null) {
throw new FlorizzException("No argument detected! Please use the correct format of 'remove <flowerName> /q <quantity> /from <bouquetName>");
throw new FlorizzException("No argument detected! " +
"Please use the correct format of 'remove <flowerName> /q <quantity> /from <bouquetName>");
}

if (!argument.matches(REMOVE_FLOWER_REGEX)) {
throw new FlorizzException("Incorrect format detected! Please use the correct format of 'remove <flowerName> /q <quantity> /from <bouquetName>");
throw new FlorizzException("Incorrect format detected! " +
"Please use the correct format of 'remove <flowerName> /q <quantity> /from <bouquetName>");
}

// [WARNING] might need to check for extra slash k
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/florizz/core/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ public void printAllOccasion() {
* @param quantity
* @param bouquetName
*/
public void printAddFlowerSuccess(ArrayList<Bouquet> bouquetList, String flowerName, Integer quantity, String bouquetName) {
public void printAddFlowerSuccess(ArrayList<Bouquet> bouquetList,
String flowerName, Integer quantity, String bouquetName) {
System.out.println("You have successfully added the following: " + System.lineSeparator() +
" - " + quantity + " x " + flowerName + " -> Bouquet: " + bouquetName);
printAllBouquets(bouquetList);
Expand All @@ -168,7 +169,8 @@ public void printAddFlowerSuccess(ArrayList<Bouquet> bouquetList, String flowerN
* @param quantity
* @param bouquetName
*/
public void printRemoveFlowerSuccess(ArrayList<Bouquet> bouquetList, String flowerName, Integer quantity, String bouquetName) {
public void printRemoveFlowerSuccess(ArrayList<Bouquet> bouquetList,
String flowerName, Integer quantity, String bouquetName) {
System.out.println("You have successfully removed the following: " + System.lineSeparator() +
" - " + quantity + " x " + flowerName + " -> Bouquet: " + bouquetName);
printAllBouquets(bouquetList);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/florizz/objects/Bouquet.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package florizz.objects;

import florizz.core.FlorizzException;


import java.util.HashMap;
import java.util.Locale;

import java.util.Objects;

public class Bouquet {
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/florizz/command/AddBouquetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ void testAddCommandExecute(){
Command testAddBouquetCommand = new AddBouquetCommand(testBouquet);
try {
testAddBouquetCommand.execute(testList, ui);
}
catch(FlorizzException error){
} catch(FlorizzException error){
ui.printError(error);
}
assertEquals(controlList, testList);
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/florizz/command/DeleteBouquetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ void testAddCommandExecute(){
controlList.remove(testBouquet);
try {
testDeleteBouquetCommand.execute(testList, ui);
}
catch(FlorizzException error){
} catch(FlorizzException error){
ui.printError(error);
}
assertEquals(controlList, testList);
Expand Down
1 change: 0 additions & 1 deletion src/test/java/florizz/command/ExitTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package florizz.command;

import florizz.command.ExitCommand;
import florizz.core.Ui;
import florizz.objects.Bouquet;
import org.junit.jupiter.api.Test;
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/florizz/command/HelpTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package florizz.command;

import florizz.command.HelpCommand;

import florizz.core.Ui;
import florizz.objects.Bouquet;
import org.junit.jupiter.api.Test;
Expand All @@ -15,7 +15,7 @@ void execute_helpCommand_true(){
// next two line might not be necessary
ArrayList<Bouquet> tempBouquetList = new ArrayList<>();
Ui ui = new Ui();
HelpCommand HelpCommand = new HelpCommand();
assertEquals(true, HelpCommand.execute(tempBouquetList, ui));
HelpCommand helpCommand = new HelpCommand();
assertEquals(true, helpCommand.execute(tempBouquetList, ui));
}
}
3 changes: 2 additions & 1 deletion src/test/java/florizz/objects/BouquetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

public class BouquetTest {
@Test
Expand Down

0 comments on commit 9088e59

Please sign in to comment.