Find Jobs
Hire Freelancers

Classes and Data Abstraction (Object Oriented Design)

$15-20 USD

已完成
已发布大约 22 年前

$15-20 USD

货到付款
Classes and Data Abstraction (Object Oriented Design) Modify the following program so that the candy machine performs the following: 1. Continue asking the user to deposit enough money till it reaches the selling price (the current program asks the user twice to put additional money and if the user doesn't put enough, the machine stops asking him and take the money) 2. Return change if there is any. (The current program doesn't return any change) I will email the whole program to the winner. The main program: (partial) // Main program: #include #include "candy.h" using namespace std; void showSelection(); void sellProduct(dispenserType& item, cashRegister& pCounter); int main() { cashRegister counter; dispenserType candy(100,50); dispenserType chips(100,65); dispenserType gum(75, 45); dispenserType cookies(100,85); int choice; // variable to hold the selection showSelection(); cin>>choice; while(choice != 9) { switch(choice) { case 1: sellProduct(candy, counter); break; case 2: sellProduct(chips, counter); break; case 3: sellProduct(gum, counter); break; case 4: sellProduct(cookies, counter); break; default: cout<<"Bad Selection"<<endl; }//end switch showSelection(); cin>>choice; }//end while return 0; }//end main void showSelection() { cout<<"*** Welcome to Shelly's Candy Shop ***"<<endl; cout<<"To select an item, enter "<<endl; cout<<"1 for Candy"<<endl; cout<<"2 for Chips"<<endl; cout<<"3 for Gum"<<endl; cout<<"4 for Cookies"<<endl; cout<<"9 to exit"<<endl; }//end showSelection void sellProduct(dispenserType& item, cashRegister& pCounter) { int amount; // variable to hold the amount entered int amount2; // variable to hold extra amount needed if([login to view URL]() > 0) //if dispenser is not empty { cout<<"Please deposit "<<[login to view URL]() <<" cents"<<endl; cin>>amount; if(amount < [login to view URL]()) { cout<<"Please deposite another " <<[login to view URL]() - amount<<" cents"<<endl; cin>>amount2; amount = amount + amount2; } if(amount >= [login to view URL]()) { [login to view URL](amount); [login to view URL](); cout<<"Collect item at the bottom and enjoy"<<endl; } else cout<<"Not enough amount. Collect what you deposited."<<endl; cout<<"*-*-*-*-*-*-*-*-*-*-*-*-*-* ## Deliverables Fuull documentation for the modified part. Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. Complete copyrights to all work purchased. ## Platform The program must work on Visual C++ and be a Win32 Console Application and C++ header.
项目 ID: 2849441

关于此项目

20提案
远程项目
活跃22 年前

想赚点钱吗?

在Freelancer上竞价的好处

设定您的预算和时间范围
为您的工作获得报酬
简要概述您的提案
免费注册和竞标工作
颁发给:
用户头像
See private message.
$10 USD 在14天之内
2.2 (5条评论)
4.2
4.2
20威客以平均价$12 USD来参与此工作竞价
用户头像
See private message.
$17 USD 在14天之内
5.0 (137条评论)
7.0
7.0
用户头像
See private message.
$12.75 USD 在14天之内
4.9 (139条评论)
5.6
5.6
用户头像
See private message.
$15.30 USD 在14天之内
4.4 (72条评论)
5.5
5.5
用户头像
See private message.
$12.75 USD 在14天之内
4.6 (60条评论)
4.5
4.5
用户头像
See private message.
$8.50 USD 在14天之内
4.9 (69条评论)
4.2
4.2
用户头像
See private message.
$17 USD 在14天之内
4.9 (18条评论)
3.9
3.9
用户头像
See private message.
$8.50 USD 在14天之内
4.2 (6条评论)
3.6
3.6
用户头像
See private message.
$14.45 USD 在14天之内
4.7 (32条评论)
3.3
3.3
用户头像
See private message.
$17 USD 在14天之内
5.0 (12条评论)
3.2
3.2
用户头像
See private message.
$8.50 USD 在14天之内
4.5 (15条评论)
2.7
2.7
用户头像
See private message.
$17 USD 在14天之内
5.0 (4条评论)
2.1
2.1
用户头像
See private message.
$17 USD 在14天之内
4.4 (6条评论)
1.6
1.6
用户头像
See private message.
$6.80 USD 在14天之内
4.0 (4条评论)
0.9
0.9
用户头像
See private message.
$14.45 USD 在14天之内
0.0 (0条评论)
1.1
1.1
用户头像
See private message.
$8.50 USD 在14天之内
0.0 (0条评论)
0.0
0.0
用户头像
See private message.
$17 USD 在14天之内
0.0 (0条评论)
0.0
0.0
用户头像
See private message.
$4.25 USD 在14天之内
0.0 (0条评论)
0.0
0.0
用户头像
See private message.
$17 USD 在14天之内
0.0 (0条评论)
0.0
0.0
用户头像
See private message.
$3.40 USD 在14天之内
0.0 (0条评论)
0.0
0.0

关于客户

UNITED STATES的国旗
United States
4.6
8
会员自4月 8, 2002起

客户认证

谢谢!我们已通过电子邮件向您发送了索取免费积分的链接。
发送电子邮件时出现问题。请再试一次。
已注册用户 发布工作总数
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
加载预览
授予地理位置权限。
您的登录会话已过期而且您已经登出,请再次登录。