简易的java-排课程序

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

//Class.javapackagecom.youngmaster;publicclassClass{privateStringname;//班级名称privateintid;//班级号privateintnumber;//班级人数privateSequencecs;publicClass(){}publicClass(intid,Stringname,intnumber){this.name=name;this.number=number;this.id=id;setCs(newSequence());}publicStringgetName(){returnname;}publicvoidsetName(Stringname){this.name=name;}publicintgetNumber(){returnnumber;}publicvoidsetNumber(intnumber){this.number=number;}publicintgetId(){returnid;}publicvoidsetId(intid){this.id=id;}publicSequencegetCs(){returncs;}publicvoidsetCs(Sequencecs){this.cs=cs;}}===============================//ClassDemo.javapackagecom.youngmaster;importjava.io.*;importjava.util.Date;importjava.util.Calendar;importjxl.*;importjxl.write.*;publicclassClassDemo{publicvoidprint()throwsException{WritableWorkbookbook=Workbook.createWorkbook(newFile(Teaching.xls));WritableSheetsheet=book.createSheet(第一页,0);Label[]label=newLabel[5];label[0]=newLabel(0,0,星期);label[1]=newLabel(1,0,日期);label[2]=newLabel(2,0,剑锋);label[3]=newLabel(3,0,秋静);label[4]=newLabel(4,0,秦少游);for(Labell:label){sheet.addCell(l);}//输出日期for(inti=1;i365;i++){Calendarcal=Calendar.getInstance();cal.add(Calendar.DATE,i-1);doublem=cal.get(Calendar.DAY_OF_WEEK);jxl.write.Numbernumber=newjxl.write.Number(0,i,m);sheet.addCell(number);Datedate=cal.getTime();jxl.write.DateTimedt=newjxl.write.DateTime(1,i,date);sheet.addCell(dt);}book.write();book.close();}publicstaticvoidmain(String[]args){ClassDemocd=newClassDemo();try{cd.print();}catch(Exceptione){System.out.println(e);}}}===============================//ClassRoom.javapackagecom.youngmaster;publicclassClassRoom{privateStringname;//教室名称privateintid;//教室号privateintnumber;//教室容纳人数publicClassRoom(){}publicClassRoom(intid,Stringname,intnumber){this.name=name;this.id=id;this.number=number;}publicStringgetName(){returnname;}publicvoidsetName(Stringname){this.name=name;}publicintgetId(){returnid;}publicvoidsetId(intid){this.id=id;}publicintgetNumber(){returnnumber;}publicvoidsetNumber(intnumber){this.number=number;}}===============================//Course.javapackagecom.youngmaster;publicclassCourse{privateStringname;//课程名称privateinttimes;//课时数privateinttimesWeek;privateintid;//课程号publicintgetId(){returnid;}publicvoidsetId(intid){this.id=id;}publicintgetTimes(){returntimes;}publicvoidsetTimes(inttimes){this.times=times;}publicCourse(){}publicCourse(intid,Stringname,inttimes,inttimesWeek){this.name=name;this.id=id;this.times=times;this.timesWeek=timesWeek;}publicStringgetName(){returnname;}publicvoidsetName(Stringname){this.name=name;}publicintgetTimesWeek(){returntimesWeek;}publicvoidsetTimesWeek(inttimesWeek){this.timesWeek=timesWeek;}}===============================//OrderCourse.javapackagecom.youngmaster;importjava.util.LinkedList;importjava.util.Random;importjava.util.TreeSet;publicclassOrderCourse{privateTeachert1,t2,t3;privateClassc1,c2,c3;privateCoursecs1,cs2,cs3;privateClassRoomcr1,cr2,cr3;privateLinkedListCoursecsList;privateLinkedListClassRoomcrList;privateLinkedListTeachertList;privateLinkedListClasscList;//已经排成的时间段LinkedListStringsub1;LinkedListStringsub2;LinkedListStringsub3;//LinkedListStringtemList1;LinkedListStringtemList2;publicOrderCourse(){//设置老师t1=newTeacher(1001,剑锋);t2=newTeacher(1002,秋静);t3=newTeacher(1003,秦少游);tList=newLinkedListTeacher();tList.add(t1);tList.add(t2);tList.add(t3);//设置上课班级c1=newClass(0601,JAVA0601班,20);c2=newClass(0602,JAVA0602班,25);c3=newClass(0603,JAVA0603班,19);cList=newLinkedListClass();cList.add(c1);cList.add(c2);cList.add(c3);//设置课程cs1=newCourse(1001,javabase,29,6);cs2=newCourse(1002,jsp,35,6);cs3=newCourse(1003,oracle,51,6);csList=newLinkedListCourse();csList.add(cs1);csList.add(cs2);csList.add(cs3);//设置上课教室cr1=newClassRoom(1001,实验楼303,50);cr2=newClassRoom(1002,南方商务大厦,40);cr3=newClassRoom(1003,先锋公司,30);crList=newLinkedListClassRoom();crList.add(cr1);crList.add(cr2);crList.add(cr3);}publicvoidinitShow(){System.out.println(目前排课的资源情况如下:);System.out.println(教师情况);for(Teachert:tList){System.out.println(教师ID:+t.getId()+教师姓名:+t.getName());}System.out.println(教室情况);for(ClassRoomcr:crList){System.out.println(教室ID:+cr.getId()+教室名称:+cr.getName()++cr.getNumber());}System.out.println(课程情况);for(Coursecs:csList){System.out.println(课程ID:+cs.getId()+课程名称:+cs.getName()+课时数:+cs.getTimes()+每周课时+cs.getTimesWeek());}System.out.println(班级情况);for(Classc:cList){System.out.println(班级ID:+c.getId()+班级名称:+c.getName()+班级人数:+c.getNumber());}}//增加排课资源数publicvoidadd(){}//从LinkedListString中随机取出timesWeek个元素组成的LinkedListStringpublicLinkedListStringrandList(LinkedListStringlist,inttimesWeek){LinkedListStringsubList=newLinkedListString();Randomrand=newRandom();intj=0;while(true){Stringm=list.get(rand.nextInt((list.size()-1)));if(!subList.contains(m)){subList.add(m);j++;}if(j==timesWeek){break;}}returnsubList;}//对随机时间段排序publicTreeSetStringlistToTree(LinkedListStringsub){TreeSetStringset=newTreeSetString(sub);returnset;}publicTreeSetStringAllTree(LinkedListStringsub1,LinkedListStringsub

1 / 13
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功