Task 6a - Enums

6a.1

Define two enums for Gender and Month. Gender is enumeration of two values i.e. Male and Female. and Month is enumeration of January, February, ... up to December. Month enum shall also store the number of days of each month.

Define User class with id, name, gender and birthMonth attributes. Use above created enums for gender and birthMonth. Create an object of User class, initialize by user input (gender shall be initialized by constructor and birthMonth shall be initialized by set method), and print all attributes values of user object.

___________


6a.2

Define EnumTest class, in main method, iterate the Month enum (created in 6a.1) to print all months' names and number of days of each month. Also iterate the Month enum to print subset of list e.g. Sep to Dec.


Comments