Further simplify code
This commit is contained in:
@@ -82,13 +82,14 @@ public:
|
|||||||
char direction = line[0];
|
char direction = line[0];
|
||||||
int amount = std::stoi(line.substr(1));
|
int amount = std::stoi(line.substr(1));
|
||||||
|
|
||||||
if (direction == 'L') {
|
switch (direction) {
|
||||||
|
case 'L':
|
||||||
dial.TurnLeft(amount);
|
dial.TurnLeft(amount);
|
||||||
}
|
break;
|
||||||
else if (direction == 'R') {
|
case 'R':
|
||||||
dial.TurnRight(amount);
|
dial.TurnRight(amount);
|
||||||
}
|
break;
|
||||||
else {
|
default:
|
||||||
assert(false && "Invalid direction");
|
assert(false && "Invalid direction");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,13 +109,14 @@ public:
|
|||||||
char direction = line[0];
|
char direction = line[0];
|
||||||
int amount = std::stoi(line.substr(1));
|
int amount = std::stoi(line.substr(1));
|
||||||
|
|
||||||
if (direction == 'L') {
|
switch (direction) {
|
||||||
|
case 'L':
|
||||||
clicksAtZero += dial.TurnLeft(amount);
|
clicksAtZero += dial.TurnLeft(amount);
|
||||||
}
|
break;
|
||||||
else if (direction == 'R') {
|
case 'R':
|
||||||
clicksAtZero += dial.TurnRight(amount);
|
clicksAtZero += dial.TurnRight(amount);
|
||||||
}
|
break;
|
||||||
else {
|
default:
|
||||||
assert(false && "Invalid direction");
|
assert(false && "Invalid direction");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user