影院售票系统java代码 java简单电影院买票代码( 二 )


}
class MyThread1 extends Thread {
// 重写run方法
public synchronized void run() {
while (ticket100) {
++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 (ticket100) {
++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 (ticket100) {
++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 (ticket100) {
++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 (ticket100) {
++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();
}
}
自己改一下 包名吧 , 这个题目是很多学校在多线程都用来的基础练习题 。
电影院售票的求大虾们帮我做一个电影院售票系统(C#,java都行)CS或者BS结构都行 ,很急 请大虾们帮帮忙这是我以前写的
#includestdio.h
#includestring.h
#define N 99 //票数容量
struct Date
{
int year;
int month;
int day;
};
struct Word
{
char movie[20]; //片名
struct Date time; //上映日期
int price; //票价
int spare; //剩余票数
}a[N],t;
void newticket(FILE *fp)
{
printf("片名:");
scanf(" %s",t.movie);
printf("日期:(例如 2014 1 25)\n");
scanf("%d%d%d",t.time.year,t.time.month,t.time.day);
printf("票价:");
scanf(" %d",t.price);
printf("剩余票数:");
scanf(" %d",t.spare);
if(t.spare!=0) //余票不为0
fprintf(fp,"%-20s %4d-%02d-%02d %3d %3d\n",t.movie,t.time.year,\
t.time.month,t.time.day,t.price,t.spare);
fclose(fp);
}
void look(FILE *fp)
{
int i,n=0;
// char ch;
fclose(fp);
fp=fopen("电影票.txt","r");
for(i=0;iN;i++)
{
fscanf(fp,"%s %d-%d-%d %d %d\n",a[i].movie,a[i].time.year,\
a[i].time.month,a[i].time.day,a[i].price,a[i].spare);
if(a[i].spare0)n++;
}
for(i=0;in;i++)
printf("%-20s %4d-%02d-%02d %3d %3d\n",a[i].movie,a[i].time.year,\
a[i].time.month,a[i].time.day,a[i].price,a[i].spare);
fclose(fp);
}
void menu()
{
printf("========电影票管理系统========\n");
printf("1.添加售票2.余票查询\n0.退出程序\n");
printf("==============================\n");
printf("功能选项:");
}
int main()

推荐阅读