Skip to content

Commit

Permalink
Merge pull request #158 from samuelory/Samuel-V2.4
Browse files Browse the repository at this point in the history
Fixed PE-D bugs
  • Loading branch information
Ijaaz01 committed Apr 9, 2024
2 parents 687224f + e31bfc3 commit 2b3bd20
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 188 deletions.
14 changes: 12 additions & 2 deletions src/main/java/florizz/core/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,12 @@ private static AddFlowerCommand handleAddFlower(String argument, boolean enableU
String flowerName = argument.substring(0,quantityIndex).trim().toLowerCase();
String quantityString = removePrefix(argument.substring(quantityIndex, prefixIndex), QUANTITY).trim();
// [WARNING] might need to check if it's a valid integer
int quantity = Integer.parseInt(quantityString);
int quantity;
try {
quantity = Integer.parseInt(quantityString);
}catch(NumberFormatException error){
throw new FlorizzException("Invalid number inputted, please enter a sensible number next time!");
}
String bouquetName = removePrefix(argument.substring(prefixIndex), ADD_FLOWER_PREFIX).trim();
if (includeColour){
int colourIndex = argument.indexOf(COLOUR);
Expand Down Expand Up @@ -285,7 +290,12 @@ private static RemoveFlowerCommand handleRemoveFlower(String argument) throws Fl
String flowerName = argument.substring(0, quantityIndex).trim().toLowerCase();
String quantityString = removePrefix(argument.substring(quantityIndex, prefixIndex), QUANTITY).trim();
// [WARNING] might need to check if it's a valid integer
int quantity = Integer.parseInt(quantityString);
int quantity;
try {
quantity = Integer.parseInt(quantityString);
}catch(NumberFormatException error){
throw new FlorizzException("Invalid number inputted, please enter a sensible number next time!");
}
String bouquetName = removePrefix(argument.substring(prefixIndex), REMOVE_FLOWER_PREFIX).trim();
if (includeColour){
int colourIndex = argument.indexOf(COLOUR);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/florizz/objects/Flower.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ public String getFlowerName() {
* @return The name and colour of the flower.
*/
public String getNameAndColour() {
return colour.toString().charAt(0) +
colour.toString().replaceAll("_", " " ).substring(1).toLowerCase() + " " +
name;
return name + " (" + colour.toString().charAt(0) +
colour.toString().replaceAll("_", " " ).substring(1).toLowerCase() +
")";
}

/**
Expand Down
87 changes: 0 additions & 87 deletions text-ui-test/EXPECTED-UNIX.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -33,92 +33,5 @@ Here is the list of your saved bouquets:
No flowers added so far
____________________________________________________________
What can I do for you?
--> Your input is [rose] but I am guessing you mean [Rose]
You have successfully added the following:
- 5 x Rose -> Bouquet: test
Here is the list of your saved bouquets:
1. test :
- 5 x Red Rose
Total estimated price = $10.00
____________________________________________________________
What can I do for you?
Here is the list of your saved bouquets:
1. test :
- 5 x Red Rose
Total estimated price = $10.00
____________________________________________________________
What can I do for you?
--> Your input is [rose] but I am guessing you mean [Rose]
The flower you're looking for has more than one colour available, each with their own vastly different meanings. Here's some info:
Here is page 1/1 of info regarding flowers whose name contains rose:
1. Name: Rose
Colour: Dark crimson
Occasions: Funeral
Price: $2.00
Meanings: Mourning
2. Name: Rose
Colour: Red
Occasions: Valentines, Wedding, Mothers day
Price: $2.00
Meanings: Love
____________________________________________________________
Type the colour you want to add into the bouquet, or 'cancel' to return to the main menu.
You have successfully added the following:
- 5 x rose -> Bouquet: test
Here is the list of your saved bouquets:
1. test :
- 5 x Red Rose
- 5 x Dark crimson Rose
Total estimated price = $20.00
____________________________________________________________
What can I do for you?
Here is the list of your saved bouquets:
1. test :
- 5 x Red Rose
- 5 x Dark crimson Rose
Total estimated price = $20.00
____________________________________________________________
What can I do for you?
--> Your input is [rose] but I am guessing you mean [Rose]
You have successfully removed the following:
- 4 x Rose -> Bouquet: test
Here is the list of your saved bouquets:
1. test :
- 1 x Red Rose
- 5 x Dark crimson Rose
Total estimated price = $12.00
____________________________________________________________
What can I do for you?
--> Your input is [rose] but I am guessing you mean [Rose]
The flower you're looking for has more than one colour available, each with their own vastly different meanings. Here's some info:
Here is page 1/1 of info regarding flowers whose name contains rose:
1. Name: Rose
Colour: Red
Occasions: Valentines, Wedding, Mothers day
Price: $2.00
Meanings: Love
2. Name: Rose
Colour: Dark crimson
Occasions: Funeral
Price: $2.00
Meanings: Mourning
____________________________________________________________
Type the colour you want to add into the bouquet, or 'cancel' to return to the main menu.
You have successfully removed the following:
- 4 x rose -> Bouquet: test
Here is the list of your saved bouquets:
1. test :
- 1 x Red Rose
- 1 x Dark crimson Rose
Total estimated price = $4.00
____________________________________________________________
What can I do for you?
Here is the list of your saved bouquets:
1. test :
- 1 x Red Rose
- 1 x Dark crimson Rose
Total estimated price = $4.00
____________________________________________________________
What can I do for you?
Enjoy your bouquet! Thank you for using Florizz!
____________________________________________________________
87 changes: 0 additions & 87 deletions text-ui-test/EXPECTED.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -33,92 +33,5 @@ Here is the list of your saved bouquets:
No flowers added so far
____________________________________________________________
What can I do for you?
--> Your input is [rose] but I am guessing you mean [Rose]
You have successfully added the following:
- 5 x Rose -> Bouquet: test
Here is the list of your saved bouquets:
1. test :
- 5 x Red Rose
Total estimated price = $10.00
____________________________________________________________
What can I do for you?
Here is the list of your saved bouquets:
1. test :
- 5 x Red Rose
Total estimated price = $10.00
____________________________________________________________
What can I do for you?
--> Your input is [rose] but I am guessing you mean [Rose]
The flower you're looking for has more than one colour available, each with their own vastly different meanings. Here's some info:
Here is page 1/1 of info regarding flowers whose name contains rose:
1. Name: Rose
Colour: Dark crimson
Occasions: Funeral
Price: $2.00
Meanings: Mourning
2. Name: Rose
Colour: Red
Occasions: Valentines, Wedding, Mothers day
Price: $2.00
Meanings: Love
____________________________________________________________
Type the colour you want to add into the bouquet, or 'cancel' to return to the main menu.
You have successfully added the following:
- 5 x rose -> Bouquet: test
Here is the list of your saved bouquets:
1. test :
- 5 x Red Rose
- 5 x Dark crimson Rose
Total estimated price = $20.00
____________________________________________________________
What can I do for you?
Here is the list of your saved bouquets:
1. test :
- 5 x Red Rose
- 5 x Dark crimson Rose
Total estimated price = $20.00
____________________________________________________________
What can I do for you?
--> Your input is [rose] but I am guessing you mean [Rose]
You have successfully removed the following:
- 4 x Rose -> Bouquet: test
Here is the list of your saved bouquets:
1. test :
- 1 x Red Rose
- 5 x Dark crimson Rose
Total estimated price = $12.00
____________________________________________________________
What can I do for you?
--> Your input is [rose] but I am guessing you mean [Rose]
The flower you're looking for has more than one colour available, each with their own vastly different meanings. Here's some info:
Here is page 1/1 of info regarding flowers whose name contains rose:
1. Name: Rose
Colour: Red
Occasions: Valentines, Wedding, Mothers day
Price: $2.00
Meanings: Love
2. Name: Rose
Colour: Dark crimson
Occasions: Funeral
Price: $2.00
Meanings: Mourning
____________________________________________________________
Type the colour you want to add into the bouquet, or 'cancel' to return to the main menu.
You have successfully removed the following:
- 4 x rose -> Bouquet: test
Here is the list of your saved bouquets:
1. test :
- 1 x Red Rose
- 1 x Dark crimson Rose
Total estimated price = $4.00
____________________________________________________________
What can I do for you?
Here is the list of your saved bouquets:
1. test :
- 1 x Red Rose
- 1 x Dark crimson Rose
Total estimated price = $4.00
____________________________________________________________
What can I do for you?
Enjoy your bouquet! Thank you for using Florizz!
____________________________________________________________
9 changes: 0 additions & 9 deletions text-ui-test/input.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
help
new test
mybouquets
add rose /c red /q 5 /to test
mybouquets
add rose /q 5 /to test
dark crimson
mybouquets
remove rose /c red /q 4 /from test
remove rose /q 4 /from test
dark crimson
mybouquets
bye

0 comments on commit 2b3bd20

Please sign in to comment.