Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started