How to use a switch statement with enum efficiently?
https://softwareengineering.stackexchange.com/questions/126886
-
03-11-2019 - |
题
I would like to know how I can use a switch
statement with enum
values for the following scenarios:
I am making a small program for a flight reservation system. The program is meant to enter certain details about the passenger. The program also restricts the user to choose destinations other than the following 3 destinations. Once destination is chosen, the flight number is supposed to be automatically assigned. The user will choose one of three destinations and program will assign an appropriate Flight No for the passenger.
The Flight No will be assigned as below:
Destination Flight No.
London 201
Frankfurt 233
Berlin 241
So let's say I make an enum
of destinations, then how can I use switch statement here? This isn't a homework. I am doing it just for the sake of exploring.
没有正确的解决方案