1
到目前爲止,我編寫的代碼使得表格看起來有點像Excel中的表格,並且我能夠在編譯時輸入字母單詞,但我不能說例如1a等於5並且使1a中的單元格顯示5這是我的桌子到目前爲止的樣子。這是我的代碼編制表:如何將數字輸入到表格的單元格中?
package table;
public class Spreadsheat {
private int xVal = 137;
private int yVal = 1;
private int[][] table = new int [20][20];
private char yaxis = 'A';
private int xaxis = 0;
public Spreadsheat(){
for(int i = 0; i < xVal; i++){
System.out.print("-");
}
System.out.println();
System.out.print(" |");
for(int i = 0; i < 17; i++){
System.out.print("| " + yaxis + "\t" + "|");
yaxis = (char) (yaxis + 1);
}
System.out.println();
for(int i = 0; i < xVal; i++){
System.out.print("-");
}
System.out.println();
for(int j = 0; j <10;j++){
System.out.print(" " + xaxis + "|");
for(int i = 0; i < 17; i++){
System.out.print("|" + "\t" + "|");
}
System.out.println();
xaxis = xaxis + 1;
}
}
public void setxval(int xVal) {
this.xVal = xVal;
}
public int getxVal() {
return xVal;
}
public void setyVal(int yVal) {
this.yVal = yVal;
}
public int getyVal() {
return yVal;
}
public void setTable(int table[][]) {
this.table = table;
}
public int[][] gettable() {
return table;
}
}
這是我的客戶端程序:
package Client;
import java.util.Scanner;
import table.Spreadsheat;
public class VisiCalc {
public static void main(String[] args){
Scanner kb = new Scanner(System.in);
Spreadsheat table = new Spreadsheat();
boolean end = false;
while(end == false){
String input = kb.next();
System.out.println(input);
if(input.contains("quit")){
end = true;
}
}
}
}
隨機評論:電子表格,'ee'不是'ea' ... – Jon 2012-03-27 03:42:31
是的,我真的這麼做很晚 – user1294516 2012-03-27 04:02:01