A chikcken farmer receives from a supplier young chickens that he raises until they have the weight needed for marketing. A chicken is characterized by its weight and an identification number. The price of a chicken varies according to the price of the day and the weight. Suppose that the price of the day is 5 riyals per kilo. So for a chicken with a weight 3.4 kilograms the price will be 17 riyals. The price of the day (dailyPrice) and the necessary weight to market a chicken ( necessaryWeight) are the same for all chickens. By default dailyPrice = 8 and necessaryWeight=1.5
Write the Chicken class according to the class diagram below:
getWeight and setWeight methods corresponds to getter and setter for the weight attribute.
- setDailyPrice : set the new daily price for all chickens. • setNecessaryWeight: set the necessary weight to market a chicken.
- canMarket : return true if the weight of a chicken is grater or equal to the necessary weight and false otherwise.
- Price : return the price of chicken (weight * dailyPrice) if the chicken have the necessary weight and 0 otherwise.
- Print : print the id and the weight of the chicken. If the chicken is ready for market print “ready for market” and give the price. Otherwise print “dont have the necessary weight”.
Define a driver class that contains a main method and test the functionality of the above class.