add a new method
I add a method for manipulation individual fields.
This commit is contained in:
parent
bd45b3b891
commit
140b8e852f
Binary file not shown.
Binary file not shown.
@ -29,6 +29,9 @@
|
||||
* adds a row to the inner data structure.
|
||||
* without writing into the CSV-file.
|
||||
*
|
||||
* set (row : int, column : int, item : string) : void
|
||||
* replaces the specified item with a newer.
|
||||
*
|
||||
* commit() : void
|
||||
* writes the added data into CSV-file.
|
||||
*
|
||||
@ -711,4 +714,24 @@ public class CSVFile {
|
||||
return table.size();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param row
|
||||
* @param column
|
||||
* @param item
|
||||
* @purpose replaces the specified item with a newer.
|
||||
*/
|
||||
public void set(int row, int column, String item) {
|
||||
if (row < table.size()) {
|
||||
if (column < table.get(row).size()) {
|
||||
table.get(row).set(column, item);
|
||||
} else {
|
||||
throw new RuntimeException("set: column is too large!");
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("set: row is too large!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -121,5 +121,13 @@ public class TestCSVFile {
|
||||
// test successful
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSet() {
|
||||
// CSVFile testObj = new CSVFile("testData4.csv",',');
|
||||
// testObj.set(6, 2, "80");
|
||||
// testObj.updateFile();
|
||||
// test succesfull
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -4,4 +4,4 @@
|
||||
4,68.2166,142.3354
|
||||
5,67.78781,144.2971
|
||||
7,69.80204,141.4947
|
||||
8,70.01472,136.4623
|
||||
8,70.01472,80
|
||||
|
|
Loading…
Reference in New Issue
Block a user