forked from nus-cs2113-AY2324S2/tp
-
Notifications
You must be signed in to change notification settings - Fork 0
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 nus-cs2113-AY2324S2#19 from Ijaaz01/MohamedIjaaz-F…
…lowerCommand Add flower command and flower dictionary
- Loading branch information
Showing
6 changed files
with
107 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package florizz.command; | ||
|
||
import florizz.core.FlorizzException; | ||
import florizz.core.Ui; | ||
import florizz.objects.Bouquet; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class FlowerCommand extends Command{ | ||
private String occasion; | ||
|
||
public FlowerCommand(String occasion) { | ||
this.occasion = occasion; | ||
} | ||
|
||
@Override | ||
public boolean execute(ArrayList<Bouquet> bouquetList, Ui ui) throws FlorizzException { | ||
if (occasion.isBlank()) { | ||
ui.printAllDictFlowerName(); | ||
} else { | ||
ui.printOccasionFlower(occasion); | ||
} | ||
return true; | ||
} | ||
} |
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,53 @@ | ||
package florizz.core; | ||
|
||
import java.util.ArrayList; | ||
import florizz.objects.Flower; | ||
|
||
/** | ||
* A class that contains a dictionary of preset flowers | ||
*/ | ||
public class FlowerDictionary { | ||
private static ArrayList<Flower> flowerDict = new ArrayList<Flower>(); | ||
|
||
/** | ||
* Adds a new flower to the flower dictionary | ||
* | ||
* @param name Name of flower to be added | ||
* @param colour Colour of flower to be added | ||
* @param occasion Occasion that the flower is bought for | ||
*/ | ||
public static void add(String name, String colour, String occasion) { | ||
flowerDict.add(new Flower(name, colour, occasion)); | ||
} | ||
|
||
/** | ||
* Adds flowers to the dictionary when florizz starts up (temporary) | ||
*/ | ||
public static void startup() { | ||
add("Orchid", "White", "Wedding"); | ||
add("Rose", "Red", "Valentines"); | ||
add("Lily", "White", "Funeral"); | ||
add("Daisy", "White", "Valentines"); | ||
add("Babys Breath", "White", "Wedding"); | ||
add("Chrysanthemum", "White", "Funeral"); | ||
} | ||
|
||
/** | ||
* Returns the size of flower dictionary | ||
* | ||
* @return The size as an int | ||
*/ | ||
public static int size() { | ||
return flowerDict.size(); | ||
} | ||
|
||
/** | ||
* Gets the flower at the selected index in the flower dictionary | ||
* | ||
* @param i Index to get flower from | ||
* @return The flower object at index i | ||
*/ | ||
public static Flower get(int i) { | ||
return flowerDict.get(i); | ||
} | ||
} |
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