📄 arraytest.java
字号:
package day05;
public class ArrayTest {
public static void main(String[] args) {
char classDegree='M';
char postion='S';
int[] windowSeatIndex={0,5};
int[] centerSeatIndex={1,4};
int[] sideSeatIndex={2,3};
char[][] seats=new char[32][6];
for(int i=0;i<seats.length;i++){
for(int j=0;j<seats[i].length;j++){
seats[i][j]='E';
}
}
int fromRow=0,toRow=0;
switch(classDegree){
case 'F':fromRow=1;toRow=5;break;
case 'M':fromRow=6;toRow=20;break;
case 'B':fromRow=21;toRow=32;break;
}
int[] userPostion=null;
switch(postion){
case 'W': userPostion=windowSeatIndex;break;
case 'C': userPostion=centerSeatIndex;break;
case 'S': userPostion=sideSeatIndex;break;
}
boolean wasOrder=false;
loop: for(int i=fromRow;i<=toRow;i++){
for(int j=0;j<userPostion.length;j++){
if(seats[i][userPostion[j]]=='E'){
System.out.println("you seat is :"+i+(char)(userPostion[j]+'A'));
seats[i][userPostion[j]]='O';
wasOrder=true;
break loop;
}
}
}
if(!wasOrder){
System.out.println("对不起,没有您要的座位!");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -