十万火急JAVA新手求助

问题描述

importjava.util.*;publicclassPrison{privatestaticDatetoday;privatebooleanquit;privatePrisoner[]prisoners=newPrisoner[10];publicintindex=0;privatedoublecellNo;intd=1;privateDate[]dates=newDate[20];privateString[]prisonerDetail=newString[5];privateString[]cellDetail=newString[5];privatestaticvoidstart(){today=newDate(1,1,2011);}publicstaticDatetoday(){returntoday;}publicstaticvoidmain(Stringargs[]){newPrison();}publicintindex(){returnindex;}publicPrison(){start();action();while(quit!=true){readChoose();}}publicvoidaction(){System.out.println("ShortBayPrison");}privatevoidreadChoose(){System.out.print("nAction(or?):");charnextIn=Character.toUpperCase(In.nextChar());switch(nextIn){case'N':add();break;case'A':allocate();break;case'P':showDetails();break;case'C':showCell();break;case'?':explain();break;case'X':exit();break;default:error();}}privatevoidadd(){Stringn,c;intl;intday=0;intm=0;inty=0;inttotal=0;System.out.print("name:");n=In.nextLine();System.out.print("Crime:");c=In.nextLine();System.out.print("Level:");l=In.nextInt();System.out.print("Days:");day=In.nextInt();System.out.print("Months:");m=In.nextInt();System.out.print("Years:");y=In.nextInt();total=day+(m*30)+(y*365);dates[index]=newDate(today());dates[index].add(total);prisoners[index]=newPrisoner(n,c,l,d);Strings=""+d+""+n+"n"+c+":"+"start"+today()+",end"+dates[index]+",period"+day+"/"+m+"/"+y;System.out.print(s);prisonerDetail[index]=s;index++;d++;}privatevoidallocate(){intb;System.out.print("Prisonerid(0toexit):");d=In.nextInt();}publicvoidshowDetails(){intc=0;System.out.print("Theprisonersare");for(inti=0;i<prisonerDetail.length;i++)if(prisonerDetail[i]==(null)){prisonerDetail[i]="";c++;if(c==prisonerDetail.length)System.out.println("nnone");}else{System.out.println("n"+prisonerDetail[i]);}}privatevoidshowCell(){intc=0;System.out.print("Cellallocationis");for(inti=0;i<cellDetail.length;i++)if(cellDetail[i]==(null)){cellDetail[i]="";c++;if(c==cellDetail.length)System.out.println("nnone");}else{System.out.println("n"+cellDetail[i]);}}privatevoidexplain(){System.out.print("Thechoicesare"+"n"+"N:Newprisoner"+"n"+"A:Allocateacell"+"n"+"P:Showprisoners"+"n"+"C:Showcellallocation"+"n"+"?:Explainthechoices"+"n"+"X:Exitthesystem"+"n");}publicvoiderror(){System.out.println("Thatwasnotavalidchoice.");System.out.print("nEnteranewaction(?forhelp).");}publicvoidexit(){quit=true;System.exit(0);}}以上是我代码,在allocation那一块,要求在这个有2层楼,一层10个房间,单数房间放1个犯人,双数房间能放2个犯人,3个不同级别的犯人不能关在一起,同级别的可以关在偶数房间里,房间代码是1.1;1.2;.....1.102.1;2.2...2.20跪求高手解答,在线坐等这是要求的运行时的模板求高手解答.....十万火急ShortBayPrisonAction(or?):?ThechoicesareN:NewprisonerA:AllocateacellP:ShowprisonersC:Showcellallocation?:ExplainthechoicesX:ExitthesystemAction(or?):erThatwasnotavalidchoice.Enteranewaction(?forhelp).Action(or?):pTheprisonersarenoneAction(or?):cCellallocationisnoneAction(or?):xShortBayPrisonAction(or?):nName:fredCrime:litteringLevel:1Days:3Months:0Years:01fredlittering:start1/1/2011,end4/1/2011,period3/0/0Action(or?):aPrisonerid(0toexit):1fredisintheonlybunkofcell1.1Action(or?):nName:johnCrime:arsonLevel:3Days:2Months:3Years:42johnarson:start1/1/2011,end2/4/2015,period2/3/4Action(or?):aPrisonerid(0toexit):2johnisinthetopbunkofcell1.2Action(or?):nName:tomCrime:badhairLevel:1Days:4Months:0Years:03tombadhair:start1/1/2011,end5/1/2011,period4/0/0Action(or?):aPrisonerid(0toexit):3tomisintheonlybunkofcell1.3Action(or?):pTheprisonersare1fredlittering:start1/1/2011,end4/1/2011,period3/0/02johnarson:start1/1/2011,end2/4/2015,period2/3/43tombadhair:start1/1/2011,end5/1/2011,period4/0/0Action(or?):cCellallocationisCell1.1has1fredCell1.2has2johnCell1.3has3tomAction(or?):nName:georgeCrime:assaultLevel:3Days:2Months:3Years:14georgeassault:start1/1/2011,end2/4/2012,period2/3/1Action(or?):aPrisonerid(0toexit):4georgeisinthebottombunkofcell1.2Action(or?):cCellallocationisCell1.1has1fredCell1.2has2john,4georgeCell1.3has3tomAction(or?):aPrisonerid(0toexit):43Thatwasnotavalidid.Valididsare1,2,3,4Prisonerid(0toexit):0Action(or?):aPrisonerid(0toexit):11fredalreadyhasacell.TryagainPrisonerid(0toexit):0Action(or?):x

解决方案

解决方案二:
一团浆糊,不知所云。
解决方案三:
希望你能把代码的核心部分贴出来,你贴这么长让人感觉到畏惧

时间: 2024-08-29 03:36:47

十万火急JAVA新手求助的相关文章

关于java问题-Java新手求助,纠结了好久了!

问题描述 Java新手求助,纠结了好久了! 学Java没几天,看的是毕向东的视频.结合书本来看.但是我看书本上面类的前面都加public,而他的视频上面没有加,这是怎么回事?难道他教的过时了吗? 解决方案 加public表示为全局类,该类可以被任何类引用 不加public为默认保留类,只能在其同一包下的类引用. 解决方案二: 类公开 属性私有 错不了 都加 解决方案三: 类公开 属性私有 错不了 都加 解决方案四: 加了public说明这是一个全局类,可以被其他任何类引用.没有加public说明

软件工程-java 新手求助,老师让做个课程表

问题描述 java 新手求助,老师让做个课程表 建一个课程表. 星期四:三,四节:计算与软件工程:仙2-407: 通过命令行方式完成对课程的增.删.改.查.显示. Add 星期四:三,四节:计算与软件工程:仙2-407://如果成功 显示"已添加到文件中" Remove 星期四:三,四节:计算与软件工程:仙2-407://如果成功 显示"已从文件删除" Update 星期四:三,四节:计算与软件工程:仙2-408://如果成功 显示"已更新文件"

各位大神好,Java新手求助

问题描述 做了一个网站,有支付功能的,在公司的服务器上测试没有什么问题,可是放到客户的服务器上,支付页面成了页面的源码了,后来调试了一下,把浏览器改成兼容性浏览就好了!所以出现了这种情况,应该怎么弄,求教个问大神,在下谢谢了这个问题很急,在线等,请管理员不要删帖,谢谢了 解决方案 解决方案二:是IE浏览器吗?参考解决方案三:换其他浏览器测试看看呢.

string-新手Java问题求助,很急。

问题描述 新手Java问题求助,很急. public class C { public static void main(String[] args) { // TODO 自动生成的方法存根 String s1 = new String("Hello!"); String s2 = new String("I love JAVA."); A1 s=new A1(s1,s2); System.out.println("1号"+s1 + s2); S

string-java新手求助:学到方法了,遇到一题目,已经解出,但求更多的解决方法。

问题描述 java新手求助:学到方法了,遇到一题目,已经解出,但求更多的解决方法. 新手学习,刚学到了方法,但其中但参数和方法调用其实不是很明白.跟着课本做了一道题.附上题目和我的代码.请求各方面的指点,改进我的代码也好.指出不对的也好.提供新的解题方法或代码的也好,多多益善: 题目如下: 一个五角数被定义为n(3n-1)/2,其中n=1,2,3,4,5··············所以,开始的几个数字就是1,5,12,22 编写下面的方法,返回一个五角数. public static int g

多线程问题-新手求助关于Java多线程中启动线程问题

问题描述 新手求助关于Java多线程中启动线程问题 public class Example15_1 { /** * @param args */public static void main(String[] args) { // TODO Auto-generated method stub SpeakHello speakHello; SpeakNinhao speakNinhao; speakHello = new SpeakHello(); speakNinhao= new Speak

java装饰着模式问题,新手求助

问题描述 java装饰着模式问题,新手求助 本人新手,在java head first设计模式中装饰模式遇到个问题请教大家,问题就是设置饮料杯子的大小,根据杯子大小加上各自的价钱,写的代码如下,不知道为什么结果却不会根据设置的大小加上价钱?感觉应该SizeDecorator中的cost()方法有问题,但是又试不出来,求指点,谢谢 public abstract class Beverage { String description="Unknown Beverage"; String

java try-catch 新手求助

问题描述 java try-catch 新手求助 public static void main(String[] args) { Scanner input1=new Scanner(System.in); String[] books={"","军事","历史","建筑","文学","数学","计算机","小说","百科"}

java AS新手求助。以下是代码:

问题描述 java AS新手求助.以下是代码: setOnCheckedChangeListener方法参数类型不匹配 ackage gke_code_jrxd.Demo.ui; import android.app.Activity; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentTransaction; import