查看單個文章
舊 2007-07-16, 11:54 AM   #3 (permalink)
garfieldking
榮譽勳章

勳章總數
UID -
在線等級:
文章: n/a
精華:
預設

基本上它是一個5*5 dimension的array

c0 c1 c2 c3 c4
------|------|-----|-----|-----|-----
r0
------|------|-----|-----|-----|-----
r1
------|------|-----|-----|-----|-----
r2
------|------|-----|-----|-----|-----
r3
------|------|-----|-----|-----|-----
r4
------|------|-----|-----|-----|-----

然後我建立五個選擇給使用者
a) Edit cell value
b) Change size
c) Read from CSV file
d) Write to CSV file
e) Exit

使用者選擇上面五個功能來display 那個spread sheet
e.g 選a
接下來他就會問你要哪行哪列 e.g r2c3
然後填入一個新的value給你上面所填入的框框, e.g coke
然後r2c3就會印出coke
------------------------------------------------------------------------
這是我目前寫出來的(在下面)
只有一點點
希望懂的人可以幫幫我
謝謝
------------------------------------------------------------------------

import java.util.*;
import java.io.*;
public class spreadSheet {

//defining the private members of constant
private String[][] spreadBoard;
private String cellPos;

//creating an empty spreadsheet board initially start with 5*5
public spreadSheet(int rdim,int cdim){
spreadBoard = new String[rdim][cdim];
for(int row=5; row<spreadBoard.length; row++){
for(int col=5; col<spreadBoard.length; col++){
spreadBoard[row][col]="";
}
}
}

//creating a constructor which takes two int parameter to indicate row and columns
public spreadSheet(String[][] arr, int i, int j){
if(i<0 || j<0){
throw new IllegalArgumentException("Rows and columns are not positive numbers");
}
else{
cellPos = arr[i][j];
}
}

//creating a constructor of file object to read file
public static void main(String[] args)throws IOException{
Scanner stdin = new Scanner(System.in);

System.out.println("File: ");
String name = stdin.nextLine();
File file = new File(name);

Scanner fileIn = new Scanner(file);
while(fileIn.hasNext()){
String currentFile = fileIn.nextLine();
}
}

//creating

//a method to set cell of number of row and column to be string
public static String setCell(String[][] cel,int rnum, int cnum){
return cel[rnum][cnum];
if(rnum=="," || cnum==","){
throw new IllegalArgumentException();
}
else if(cel > spreadBoard.length){

}
}

}
 
送花文章: 0, 收花文章: 0 篇, 收花: 0 次
回覆時引用此帖