资源简介
Java实验,电话计费卡程序,编写一个程序可以测试电话通话的时间,并根据费率计费

代码片段和文件信息
import java.lang.*;
import java.io.*;
import java.sql.Time;
public class PhoneCard
{
String cardNumber ;
String passWord ;
String callNumber ;
double balance ;
double rate; //每分钟多少钱
Time startTime; //开始通话时间
Time endTime; //结束通话时间
double cost; //消费金额
int callTime; //通话时间(分钟)
public PhoneCard(String cardNumberString passWorddouble balanceString callNumber){
this.cardNumber=cardNumber;
this.passWord=passWord;
this.balance=balance;
this.callNumber=callNumber;
this.rate=2.0;
}
public void StartCall()
{
//开始时间设为当前时间
this.startTime = new Time(System.currentTimeMillis());
}
//挂断电话
public void EndCall()
{
//赋值结束时间---设为当前时间
this.endTime = new Time(System.currentTimeMillis());
int hours = this.endTime.getHours() - this.startTime.getHours();
int minutes = this.endTime.getMinutes() - this.startTime.getMinutes();
int seconds = this.endTime.getSeconds() - this.startTime.getSeconds();
//计算总时间(分钟)
this.callTime = (int)(hours * 60F + minutes + seconds/60.0F) + 1;
}
public Time GetStartTime()
{
return this.startTime;
}
//获取结束通话时间
public Time GetEndTime()
{
return this.endTime;
}
//获取开始通话时间
public float GetcallTime()
{
return this.callTime;
}
//设置通话时长(分钟) 主要用于测试
public void SetcallTime(float callTime)
{
this.callTime = (int)callTime;
}
//获取本次通话的话费
public double Getcost()
{
return this.cost;
}
public void counter()
{
cost= this.callTime * this.rate;
balance=balance-cost;
}
//打印通话信息
public String toString()
{
String message = ““;
message = “ 201卡收费标准: “ + this.rate + “元/分“;
message += “\n 通话开始时间: “ + this.startTime.toLocaleString();
message += “\n 通话结束时间: “ + this.endTime.toLocaleString();
message += “\n 通话时长(分钟): “ + this.callTime;
message += “\n 通话费用(分钟): “ + this.cost;
message += “\n 电话卡余额: “ + this.balance + “元“;
return message;
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1020 2009-12-05 16:13 java实验电话计费卡程序\TestPhoneCard.java
文件 2353 2009-12-05 16:09 java实验电话计费卡程序\PhoneCard.java
目录 0 2010-01-02 00:24 java实验电话计费卡程序
----------- --------- ---------- ----- ----
3373 3
相关资源
- android毕业设计
- android-support-v4.jar已打包进去源代码
- java23种设计模式+23个实例demo
- java Socket发送/接受报文
- JAVA828436
- java界面美化 提供多套皮肤直接使用
- 在线聊天系统(java代码)
- 基于Java的图书管理系统807185
- java中实现将页面数据导入Excel中
- java 企业销售管理系统
- java做的聊天系统(包括正规课程设计
- Java编写的qq聊天室
- 商店商品管理系统 JAVA写的 有界面
- JAVA开发聊天室程序
- 在linux系统下用java执行系统命令实例
- java期末考试试题两套(答案) 选择(
- JAVA3D编程示例(建模、交互)
- Java 文件加密传输
- java做的房产管理系统
- 基于jsp的bbs论坛 非常详细
- [免费]java实现有障碍物的贪吃蛇游戏
- java Servlet投票实例
- 操作系统作业 (pv,作业管理,等5个
- 基于C/S架构考试系统(Java)
- java access 仓库管理系统 源码
- 一元多项式相加 java实现
- java软件工程师简历模板——应届生
- DES(CFB) JAVA
- java读取局域网共享机器文件
- [免费]java学习 存储过程
评论
共有 条评论