0
How do I add initialization, copy and non-argument constructors to this code?
I'll attach the code now...
2 Réponses
0
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
class ATM
{
public:
ATM():Id(0), curentMoney(0) {}
void setId(int i) { Id = i; }
int getId(){ return Id; }
void InsertMoney(int i){
if((i < min) || (i > max)){
cout<<"Sorry, but max = 1000, min = 10";
return;
}
if((curentMoney + i) > max ){
cout<<"Please, input max = "<<max-curentMoney<<endl;
return;
}
curentMoney = i;
}
void getMoney(int i){
if((i < min) || (i > max)){
cout<<"Sorry, but max = 1000, min = 10";
return;
}
if( (curentMoney - i) < 0 ) {
cout<<"Problem"<<endl
<<"get max: "<<curentMoney<<endl;
}
curentMoney -= i;
}
void toString() const{
cout<<"current money: "<<curentMoney<<endl;
}
private:
int Id;
0
private:
int Id;
int curentMoney;
enum { max = 1000, min = 10 };
};
int main()
{
ATM bank;
bank.setId(111);
bank.InsertMoney(500);
bank.getMoney(100);
bank.toString();
cout<<bank.getId()<<endl;
return 0;
}