Question: Ex 1 : Define a class Farmer with the following specifications: Attributes: name ( private ) : The farmer s name ( default to Unknown
Ex : Define a class Farmer with the following specifications:
Attributes:
name private: The farmers name default to Unknown
crop private: The type of crop the farmer cultivates default to Wheat
experience private: The years of farming experience default to
Methods:
updateCropnewCrop: Updates the farmers crop type.
increaseExperienceyears: Adds the specified years to the farmers experience.
displayRank: Displays the farmers rank based on experience:
Sprout if less than years experience
Pro Farmer if less than years experience
Cultivator otherwise
Constructor:
Takes optional parameters for name, crop, and experience. If not provided, set default values as mentioned above.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
