Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change recommendCommand to no longer kick out user if bad input is given #154

Merged

Conversation

Ijaaz01
Copy link

@Ijaaz01 Ijaaz01 commented Apr 8, 2024

[IMPORTANT] I changed the recommend command function to no longer throw execeptions and kick out the user if they sent the wrong input. Please do take a look and request changes if something doesnt look right. As of my brief testing the only time it gets kicked out is if they input a occasion colour combi that does not have any flowers under

@Ijaaz01 Ijaaz01 added this to the v2.1 milestone Apr 8, 2024
@Ijaaz01 Ijaaz01 self-assigned this Apr 8, 2024
Comment on lines +53 to +73
/**
* Gets the name the user wants to make for the recommended bouquet and makes sure the name does not already exist
* @param ui Ui to take input and print messages
* @param bouquetList List that contains all bouquets
* @return The chosen valid bouquetName
*/
public String askBouquetName(Ui ui, ArrayList<Bouquet> bouquetList) {
boolean isValidName = false;
String bouquetName = "placeHolder";
ui.printAskBouquetName();
while (!isValidName) {
bouquetName = ui.getInput();
if (bouquetList.contains(new Bouquet(bouquetName))) {
System.out.println("Sorry a bouquet with this name already exists, please enter another name");
} else {
isValidName = true;
}
}
return bouquetName;
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should fix the naming issue, great job 👍

Comment on lines +96 to +106
boolean isValidFormat = false;
boolean isValidOccasion = false;
String occasionInput = "placeholder";
while (!(isValidFormat && isValidOccasion)) {
occasionInput = ui.printAskOccasion();
isValidFormat = Parser.parseOccasion(occasionInput);
isValidOccasion = Flower.isValidOccasion(occasionInput);
// check if occasion is in our dictionary
if (!isValidOccasion) {
System.out.println("This occasion does not exist.");
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes code more readable

Comment on lines +143 to +150
String saveInput = "placeHolder";
boolean isValidFormat = false;
boolean isValidInput = false;
while (!(isValidInput && isValidFormat)) {
saveInput = ui.printAskSaveBouquet(recommendedBouquet);
isValidFormat = Parser.parseSaveBouquet(saveInput);
isValidInput = (saveInput.equalsIgnoreCase("yes") || saveInput.equalsIgnoreCase("no"));
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isValidInput might not be necessary since parseSaveBouquet already used regex, although that one only accepts lower case input. If you didn't change parseSaveBouquet, the method might still reject capitalised yes even with equalsIgnoreCase.

Comment on lines -287 to +290
throw new FlorizzException("Incorrect format detected! " +
System.out.println("Incorrect format detected! " +
"Please input a single occasion");
return false;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good if all system.out should be done by Ui only to follow single responsibility principle. I understand why you remove the florizz exception since it kinds of stop users from inputting more command.

@samuelory samuelory merged commit fe1c5fd into AY2324S2-CS2113-T11-3:master Apr 8, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants