我是Java的新手,我在制作这个程序时遇到了麻烦。基本上我需要一个switch语句,同时嵌套2个级别的If,Else if语句和程序应该吐出的最终产品是带有文本的图像。这是代码块。
public void paint(Graphics g) {
super.paint(g);
g.drawImage(img,0,0,this);}
public void init(){
currentTime= Calendar.getInstance();
month= currentTime.get(Calendar.MONTH)+1;
System.out.printf("%d",month); //checked that it worked
GetTemp();
parsetemps();
weather();
switch (month) {
case 1: case 2: case 3: case 4: //Winter
break;
case 6: case 7: case 5:case 8: //Summer
if (t1>=60&&t1<=80) {
if (weather1.equalsIgnoreCase("Windy"))
img=getImage(getCodeBase(),"hottub.jpg");
else if (weather1.equalsIgnoreCase("Not Windy"))
img=getImage(getCodeBase(),"parasail.jpg");}
else if (t1>=81&&t1<=100){
if (weather2.equalsIgnoreCase("sunny"))
img=getImage(getCodeBase(), "parasail.jpg");
else if(weather2.equalsIgnoreCase("not sunny"))
img=getImage(getCodeBase(), "parasail.jpg");}
break;