/**
* TicketMachine是自动售票机的一个类
* The price of a ticket is specificed via the constructor.*
* @author 李宝玉
* @version 2017.03.22
*/
public class TicketMachine {
private int price;
private int balance;
private int total;
/**
* Create a machine that issues tickets of the given price.
* are no checkh to ensure this.
* @param ticketCost the price of a ticket
*/
public TicketMachine(int ticketCost){
if(ticketCost>0){
price=ticketCost;
}
balance=0;
total=0;
}
/**
* Return the price of a ticket.
* @return the price of a ticket
*/
public int getPrice()
{
return price;
}
/**
* Return the amount of money already inderted for the next ticket.
* @return the amount of money already inderted for the next ticke
*/
public int getBalance(){
return balance;
}
/**
* Receive an amount of money from a customer.
* @param amount an amount of money from a customer
*/
public void insertMoney (int amount){
if(amount>0){
balance=balance+amount;
}
else{
System.out.println("Use a positive amount:"+amount);
}
}
/**
* Print a ticket.
* Update the
*/
public void priceTicket(){
if(balance>=price){
System.out.println("##############");
System.out.println("#901路");
System.out.println("#Ticket");
System.out.println("#"+price+"元");
System.out.println("##############");
System.out.println();
total=total+price;
balance=balance-price;
}
else{
System.out.println("You must insert at least:"+(price-balance)+"more cents.");
}
}
public int refundBalance(){
int amountToRefund;
amountToRefund=balance;
balance=0;
return amountToRefund;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Java自动售票机_Java自动售票机_
共30个文件
html:20个
class:2个
java:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 2 下载量 13 浏览量
2021-10-02
10:15:04
上传
评论 2
收藏 39KB ZIP 举报
温馨提示
基于Java的自动售票机系统的设计与实现
资源推荐
资源详情
资源评论
收起资源包目录
Java自动售票机.zip (30个子文件)
Java自动售票机
自动售票机
autoTicketMachine
.project 393B
src
TicketMachine.java 2KB
Test.java 2KB
doc
package-tree.html 4KB
constant-values.html 3KB
index.html 3KB
overview-tree.html 4KB
allclasses-noframe.html 693B
index-files
index-2.html 4KB
index-3.html 4KB
index-5.html 5KB
index-1.html 4KB
index-4.html 4KB
deprecated-list.html 3KB
package-use.html 4KB
help-doc.html 7KB
Test.html 8KB
package-list 2B
allclasses-frame.html 733B
package-frame.html 841B
script.js 857B
package-summary.html 4KB
class-use
Test.html 4KB
TicketMachine.html 4KB
TicketMachine.html 11KB
stylesheet.css 13KB
.settings
org.eclipse.jdt.core.prefs 634B
.classpath 232B
bin
Test.class 2KB
TicketMachine.class 2KB
共 30 条
- 1
资源评论
- 悲伤叉烧包2021-12-16用户下载后在一定时间内未进行评价,系统默认好评。
- liuguangfu012024-01-03资源很实用,内容详细,值得借鉴的内容很多,感谢分享。
肝博士杨明博大夫
- 粉丝: 73
- 资源: 3976
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功