Consider the two classes represented in the following UML diagram. Implement the two the classes as explained
below.
-address: String
-flowers: Flower []
FlowerShop
+FlowerShop(a: String, size: int)
+fillFlowers(f: Flower []): void
+buyFlowers(flowerName: String, qtyNeeded: int): double
+toString():String
Question 1 [25 points]:
Create the class Flower as presented in the above UML:
1) Write the constructor that takes as parameters all data fields.
-name: String
-qty: int
-price: double
Flower
+Flower (n: String, q: int, p: double)
+decreaseQty(n: int): void
+toString(): String
2) Write only the getters and setters that you need to call in question 2 or part 2.
3) Write the method decreaseQty() that decreases the qty by n. The qty should be positive.
4) Write the method toString() that returns a String containing the flower's data fields.
Question 2 [45 points]:
Create the class FlowerShop as presented in the above UML that has:
As data fields:
1) A string address.
2) An array of flower objects. The size of this array is passed as a parameter to the constructor of the
class FlowerShop.
As methods:
1) A constructor that takes all attributes.
2) Write only the getters and setters that you need to call in the part 2.
3) The method fillFlowers that fills the array flowers. It takes as a parameter an array of Flower objects and
fills the array flowers.
4) The method buyFlowers: It takes as parameters the flowerName and quantity needed by the customer to
search for and:
a. If the flower is found, then the quantity should be checked; if the requested quantity is available
then the total price is returned (price*qtyNeeded) and the quantity available qty should be
decreased.
b. If the flower is not found or quantity is not available, then a message "Order can not be placed"
should be displayed.
5) A toString() method that returns a string representation of the FlowerShop.