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
enum
for 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
enum
for 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
enum
for 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
enum
for the shipping status.
- Create an object of this new type and set the value to one of the statuses.