diff --git a/Data Structures/CSVFile/bin/CSVFile.class b/Data Structures/CSVFile/bin/CSVFile.class index 866076049..62b48cac3 100644 Binary files a/Data Structures/CSVFile/bin/CSVFile.class and b/Data Structures/CSVFile/bin/CSVFile.class differ diff --git a/Data Structures/CSVFile/bin/TestCSVFile.class b/Data Structures/CSVFile/bin/TestCSVFile.class index 37f58575a..193d224c6 100644 Binary files a/Data Structures/CSVFile/bin/TestCSVFile.class and b/Data Structures/CSVFile/bin/TestCSVFile.class differ diff --git a/Data Structures/CSVFile/src/CSVFile.java b/Data Structures/CSVFile/src/CSVFile.java index f1c7849d5..627e87aff 100644 --- a/Data Structures/CSVFile/src/CSVFile.java +++ b/Data Structures/CSVFile/src/CSVFile.java @@ -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!"); + } + } + } diff --git a/Data Structures/CSVFile/src/TestCSVFile.java b/Data Structures/CSVFile/src/TestCSVFile.java index 070bdfd5c..0f63c9029 100644 --- a/Data Structures/CSVFile/src/TestCSVFile.java +++ b/Data Structures/CSVFile/src/TestCSVFile.java @@ -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 + } + } diff --git a/Data Structures/CSVFile/testData4.csv b/Data Structures/CSVFile/testData4.csv index d8450fc71..1c06bd9f9 100644 --- a/Data Structures/CSVFile/testData4.csv +++ b/Data Structures/CSVFile/testData4.csv @@ -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