Posts

Showing posts from October, 2017

Task 6a - Enums

Last Updated on: Nov. 17, 2020 6a.1 Define two enum, first for Gender and another for Month. Gender shall be enumeration of two values i.e. Male and Female. Month enum shall be defined with January, February, ... up to December as values. Month enum shall also store the number of days of each month. Define a User that shall be composed of id, name, gender and birthMonth attributes. Use above created enums for gender and birthMonth fields. Create a User object and initialize it from user input, gender shall be initialized in constructor and birthMonth shall be initialzed using set methed. After the object is initialized, print all fields' values of user object. Also print the number of days of birthMonth. ___________ 6a.2 Define EnumTest class, in main method: Iterate the Month enum (created in 6a.1) to print all months' names, ordinal value, and number of days of each month. Also iterate the Month enum to print a subset of months e.g. from Sep. to Dec. Create sub list of Month