
正文
车站购票系统代码java java火车票管理系统课程设计
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
java如何写火车站售票系统窗口?
很简单 我给你个我写的程序,你可以参考一下 不懂的问我。
public class Shoupiao {
public static void main(String[] args) {
chushou c1=new chushou("A地火车站",10);
c1.start();//调用Thread中的run方法需要用start();
chushou c2=new chushou("B地火车站",5);
c2.start();
chushou c3=new chushou("C地火车站",8);
c3.start();
try {
c1.join(); //执行完 c1 c2 c3 在继续执行 目的让结束最后输出
c2.join();
c3.join();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("结束");
}
}
//新建一个类
class chushou extends Thread{//用继承Thread的方法来实现多线程
String iname;
public void run() {
for(int i=inumber;i0;i--){
System.out.println(iname+"火车票卖出一张"+"剩余"+(i-1)+"张");
try {
Thread.sleep(100);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
int inumber;
public String getIname() {
return iname;
}
public void setIname(String iname) {
this.iname = iname;
}
public int getInumber() {
return inumber;
}
public void setInumber(int inumber) {
this.inumber = inumber;
}
public chushou(String iname, int inumber) {
this.iname = iname;
this.inumber = inumber;
}
}
相关问答
Q1: 用java语言编写一个火车站售票系统,要求如下
这个不难,我正好有个类似的模板,稍微修改下文字,调整下就可以用了。
Q2: 求一个 java+mysql做的车站售票系统,有数据库的增删改查就行了。要有完整的数据库哦,谢谢~ 100分送上
你好,这个估计很少。理由如下:
1)这个用分难求,要用工程银子,因为这个项目多数个人没有,除非公司的东西,还得做这个项目的公司;
2)即使他公司有也不敢拿,违法且项目很大,部署很难;
3)即使以上都不考虑,个人为这个分数现开发,那么也很费神,要设计数据库。工作量不少。少,要一些人天工时。
Q3: 要一个JAVA课程设计程序~火车票订票系统
可以通过百度Hi通知我
有时间可以解决你的问题
相近的要求也可以通知我
要一个JAVA****程序~火车票订票**
ES:\\D154D65A8D5BBB6380B8BA414D180D1C
Q4: 你好,请问一下java模拟5个窗口售票系统你是如何编写的,能教我一下吗?
package yaoshun.Thread;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextArea;
/*
* 多线程同步输出
*/
public class MultiThread extends JFrame {
private int ticket; // 计数变量
private JButton jButton;
private JLabel jLabel;
private JLabel jLabel1;
private JLabel jLabel2;
private JLabel jLabel3;
private JLabel jLabel4;
private JLabel jLabel5;
private JTextArea jTextArea1;
private JTextArea jTextArea2;
private JTextArea jTextArea3;
private JTextArea jTextArea4;
private JTextArea jTextArea5;
private Thread thread1;
private Thread thread2;
private Thread thread3;
private Thread thread4;
private Thread thread5;
// 构造器
public MultiThread() {
setName("火车票销售情况");
setLayout(null); // 使用绝对布局
setSize(680, 720);
setResizable(false); // 设置窗体大小不变
setLocationRelativeTo(null);// 设置窗体居中
jLabel = new JLabel("火车站售票大厅");
jLabel.setBounds(280, 20, 140, 30);
jLabel.setFont(new Font(getName(), Font.BOLD, 16)); // 设置字体大小
jLabel.setForeground(Color.BLUE); // 设置字体颜色
jLabel1 = new JLabel("售票窗1");
jLabel1.setBounds(72, 50, 80, 50);
jLabel1.setForeground(Color.red);
jLabel2 = new JLabel("售票窗2");
jLabel2.setBounds(192, 50, 80, 50);
jLabel2.setForeground(Color.red);
jLabel3 = new JLabel("售票窗3");
jLabel3.setBounds(312, 50, 80, 50);
jLabel3.setForeground(Color.red);
;
jLabel4 = new JLabel("售票窗4");
jLabel4.setBounds(432, 50, 80, 50);
jLabel4.setForeground(Color.red);
jLabel5 = new JLabel("售票窗5");
jLabel5.setBounds(552, 50, 80, 50);
jLabel5.setForeground(Color.red);
jTextArea1 = new JTextArea();
jTextArea1.setBounds(45, 100, 100, 500);
jTextArea1.setEditable(false); // 文本框不可编辑
jTextArea2 = new JTextArea();
jTextArea2.setBounds(165, 100, 100, 500);
jTextArea2.setEditable(false); // 文本框不可编辑
jTextArea3 = new JTextArea();
jTextArea3.setBounds(285, 100, 100, 500);
jTextArea3.setEditable(false); // 文本框不可编辑
jTextArea4 = new JTextArea();
jTextArea4.setBounds(405, 100, 100, 500);
jTextArea4.setEditable(false); // 文本框不可编辑
jTextArea5 = new JTextArea();
jTextArea5.setBounds(525, 100, 100, 500);
jTextArea5.setEditable(false); // 文本框不可编辑
jButton = new JButton("开始售票");
jButton.setBounds(270, 625, 140, 40);
jButton.setFont(new Font(getName(), Font.BOLD, 16));// 设置字体
jButton.setForeground(Color.blue);
thread1 = new Thread(new MyThread1());
thread2 = new Thread(new MyThread2());
thread3 = new Thread(new MyThread3());
thread4 = new Thread(new MyThread4());
thread5 = new Thread(new MyThread5());
// 为按钮添加监听器
jButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
thread1.start();
thread2.start();
thread3.start();
thread4.start();
thread5.start();
}
});
add(jLabel);
add(jLabel1);
add(jLabel2);
add(jLabel3);
add(jLabel4);
add(jLabel5);
add(jTextArea1);
add(jTextArea2);
add(jTextArea3);
add(jTextArea4);
add(jTextArea5);
add(jButton);
setVisible(true); // 设置窗体显示
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// 设置窗体关闭
}
class MyThread1 extends Thread {
// 重写run方法
public synchronized void run() {
while (ticket 100) {
++ticket;
jTextArea1.append("第" + ticket + "张票已售出" + "\n");
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
}
}
class MyThread2 extends Thread {
// 重写run方法
public synchronized void run() {
while (ticket 100) {
++ticket;
jTextArea2.append("第" + ticket + "张票已售出" + "\n");
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
}
}
class MyThread3 extends Thread {
// 重写run方法
public synchronized void run() {
while (ticket 100) {
++ticket;
jTextArea3.append("第" + ticket + "张票已售出" + "\n");
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
}
}
class MyThread4 extends Thread {
// 重写run方法
public synchronized void run() {
while (ticket 100) {
++ticket;
jTextArea4.append("第" + ticket + "张票已售出" + "\n");
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
}
}
class MyThread5 extends Thread {
// 重写run方法
public synchronized void run() {
while (ticket 100) {
++ticket;
jTextArea5.append("第" + ticket + "张票已售出" + "\n");
try {
Thread.sleep(200);
} catch (InterruptedException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
}
}
public static void main(String[] args) {
MultiThread multiThread = new MultiThread();
}
}
自己改一下 包名吧,这个题目是很多学校在多线程都用来的基础练习题。
Q5: 火车订票系统JAVA源代码
车站购票系统代码java我找车站购票系统代码java了找不到哈哈。。。自己想办法吧。。
车站购票系统代码java的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java火车票管理系统课程设计、车站购票系统代码java的信息别忘了在本站进行查找喔。




