Untitled
unknown
plain_text
a year ago
1.4 kB
3
Indexable
using namespace std;
enum machineState{
sC,
sA,
sB,
sD,
};
class Machine{
private:
machineState currentState;
int value{};
public:
Machine(){
currentState = sC;
value = 80;
}
bool metodaX(){
if(currentState == sC || currentState == sB){
currentState = sA;
return true;
}
return false;
}
bool metodaY(){
if(currentState == sD || currentState == sB){
currentState = sC;
value = 80;
return true;
}
return false;
}
bool metodaZ(){
if(currentState == sA){
currentState = sB;
value = 0;
return true;
}
return false;
}
bool metodaW(){
if(currentState == sA){
currentState = sD;
value = 0;
return true;
}
return false;
}
bool plus(){
if(currentState == sA && value + KORAK <= MAX_V){
value = value + KORAK;
return true;
}
return false;
}
bool minus(){
if(currentState == sA && value - KORAK >= MIN_V ){
value = value - KORAK;
return true;
}
return false;
}
machineState getCurrentState()const{
return currentState;
}
int getValue() const{
return value;
}
};Editor is loading...
Leave a Comment