-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenumandclass.cpp
More file actions
52 lines (46 loc) · 1.19 KB
/
enumandclass.cpp
File metadata and controls
52 lines (46 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
using namespace std;
// Define an enum to represent the four directions
enum Direction {
NORTH = 1,
EAST = 2,
WEST = 3,
SOUTH = 4
};
class Navigator {
public:
void navigate(int input) {
Direction dir; //actually not implemented
dir=static_cast<Direction>(input); //gets direction which corresponds to the input integer
int dirno =(input);
//Switch case to determine the direction based on the integer value
switch (dirno) {
case NORTH:
cout << "We are headed towards North." << endl;
break;
case EAST:
cout << "We are headed towards East." << endl;
break;
case WEST:
cout << "We are headed towards West." << endl;
break;
case SOUTH:
cout << "We are headed towards South." << endl;
break;
default:
cout << "Invalid Input" << endl;
break;
}
}
};
int abc() {
int input;
cin >> input;
Navigator navigator;
navigator.navigate(input);
return 0;
};
int main() {
abc();
return 0;
}