Creating enum Classes
Your Turn
For each of the practice items, create the necessary enum and create an object of that enum.
Practice 1: Days of the Week
There are seven days of the week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
- Create an
enumfor the days of the week. - Create an object of this new type and set the value to one of the days of the week.
Practice 2: Simulate a Traffic Light
A traffic light can be Red, Yellow, or Green.
- Create an
enumfor a traffic light. - Create an object of this new type and set the value to one of the colors.
Practice 3: Deck of Cards
A deck of cards has four suits: Clubs, Spades, Diamonds, and Hearts.
- Create an
enumfor the suits of a deck of cards. - Create an object of this new type and set the value to one of the suits.
Practice 4: Order Status
The status of an order can be: New, Processing, Shipped, and Delivered
- Create an
enumfor the shipping status. - Create an object of this new type and set the value to one of the statuses.