void User :: buyApples(){
while(1){
cout<<"How many do you want to buy? Press 0 to quit.";cin>>qq;
if(qq==0)
return ;
if(qq<= f.getnumofApples()){
if(salary>=(qq*200)){
invofApples+=qq;
salary-=(qq*200);
showsalary();
}
else{
cout<<"Not enough money"<<endl;
void homescreen();
}
}
else{
cout<<"There's not enough Apples in Stock"<<endl;
continue;
}
}
}
This code is a market with qq being input using cin.
I can change the salary and private variables that are in the User
class.
But I also need to change the private variables that are in the fruit class with int numofApples
. How can I change the numofApples
?
I can't seem to change the variable from the User class. When I tried to change it from the fruit class, the qq doesn't carry over. What do I do?