要一个JAVA课程设计程序~火车票订票系统
可以通过百度Hi通知我
有时间可以解决你的问题
相近的要求也可以通知我
要一个JAVA****程序~火车票订票**
ES:\\D154D65A8D5BBB6380B8BA414D180D1C
Java编程 假设有火车票1000张,创建10个线程模拟10个售票点,每个售票点100毫秒售出一张票。
package tmp;
public class Test {
private static int k=0;//售出票数
private static int count=1000;//总票数
private static synchronized boolean sell(int n){
if(kcount){
k++;
System.out.println(“第”+n+”售票点售出第”+k+”张票”);
return true;
}
return false;
}
static class SellPot extends Thread{//售票点
int n;//售票点编号
public SellPot(int n){
this.n=n;
}
public void run(){
while(sell(n)){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
public static void main(String[] args) {
for(int i=1;i=10;i++){
new SellPot(i).start();
}
}
}
//银行汇款
public class Test2 {
private static int k=0;//总汇款
private static synchronized void send(int m,int i,int n){
k+=m;
System.out.println(“第”+n+”个顾客进行第”+(i+1)+”次汇款,银行接收总汇款”+k);
}
static class Costum extends Thread{//售票点
int n;//顾客编号
public Costum(int n){
this.n=n;
}
public void run(){
for(int i=0;i3;i++){
send(100,i,n);//汇款100
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
public static void main(String[] args) {
for(int i=1;i=3;i++){
new Costum(i).start();
}
}
}
java编写火车售票系统
你说的这个程序应该是不难的,只不过N久没有写过javaswing 了
还有就是java没有多继承的,只有多实现接口的
继承的关键字是:extends
接口的关键字是:interface
编写一个查询火车票价的JAVA程序,求助啊
MapString,Integer ms=new HashMapString,Integer();
ms.put(“A-B”, 20);
ms.put(“A-C”, 30);
ms.put(“A-D”, 40);
ms.put(“A-E”, 50);
ms.put(“B-C”, 60);
ms.put(“B-D”, 70);
ms.put(“B-E”, 80);
ms.put(“C-D”, 90);
ms.put(“C-E”, 70);
Scanner input=new Scanner(System.in);
System.out.print(“输入出发站:”);
String strA=input.next();
System.out.print(“输入目的站:”);
String strB=input.next();
String key=(strA+”-“+strB).toUpperCase();
System.out.println(key+”火车票价钱是:”+ms.get(key));
这样?