tablevcter.java
来自「一个java开发的海运系统」· Java 代码 · 共 47 行
JAVA
47 行
package sun.com.tool;
import java.util.List;
import sun.com.domain.Box;
import sun.com.domain.Ship;
public class TableVcter {
//得到一个箱子和船的二维数组,用来显示表格
public String[][] tableView(List<Ship> list){
//遍历存放船的list来确定二维数组的第一个维数应该是多少
//sum来确定有多少行
int sum = 0;
for(int i=0;i<list.size();i++){
sum +=list.get(i).getBox().size();
}
//定义一个二维数组
String [][] str = new String[sum][9];
int option = 0;
for(int k = 0;k<list.size();k ++)
{
for(int n = 0;n<list.get(k).getBox().size();n++){
str[option][0] = list.get(k).getShipname();
str[option][1] = list.get(k).getVoyage();
str[option][2] = list.get(k).getBlno();
str[option][3] = list.get(k).getDestination();
option ++;
}
}
int m = 0;
for(Ship ship:list){
List<Box> box = ship.getBox();
for(Box b : box){
str[m][4]=b.getCntsize();
str[m][5]=b.getCnttype();
str[m][6]=b.getCntqnt();
str[m][7]=b.getCntoperator();
str[m][8]=b.getRemark();
m++;
}
}
return str;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?