first part of Lab13

This commit is contained in:
Rémi Heredero 2022-03-23 07:29:25 +01:00
parent aec719d2b8
commit c22553f0d5
5 changed files with 40 additions and 2 deletions

4
drawingTest.svg Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="500" height="700" version="1.1" xmlns="http://www.w3.org/2000/svg">
</svg>

After

Width:  |  Height:  |  Size: 224 B

View File

@ -27,7 +27,7 @@ public class GarageManager {
Object[] keys = services.keySet().toArray();
String result = "";
result += "*************************\n";
result += "*******************************\n";
result += "* Super Auto 20000 invoice ****\n";
result += "*******************************\n\n";
@ -70,6 +70,16 @@ public class GarageManager {
System.out.println(bill2);
// Complete with your code here !
try {
FileOutputStream bill = new FileOutputStream("C://tmp//bill.txt");
PrintWriter billWriter = new PrintWriter(bill);
billWriter.print(bill1 + "\n\n\n\n\n\n\n" + bill2);
billWriter.close();
} catch (Exception e) {
System.out.println("File can't be written");
e.printStackTrace();
}
}
}

View File

@ -29,6 +29,30 @@ public class ReadFileApplication {
BufferedReader csvReader = new BufferedReader(new FileReader(in));
// TODO: complete here
String line;
do {
line = csvReader.readLine();
if(line == null) break;
String[] str = new String[7];
str = line.split(";");
Point p1 = new Point();
p1.x = Integer.parseInt(str[0]);
p1.y = Integer.parseInt(str[1]);
Point p2 = new Point();
p2.x = Integer.parseInt(str[2]);
p2.y = Integer.parseInt(str[3]);
Color color = new Color(
Integer.parseInt(str[4]),
Integer.parseInt(str[5]),
Integer.parseInt(str[6])
);
lines.add(new Line(p1, p2, color));
} while (!line.isEmpty());
System.out.println(lines.size() + " shapes found in csv file.");
csvReader.close();
@ -50,7 +74,7 @@ public class ReadFileApplication {
* Entry point of the program
*/
public static void main(String[] args) {
Vector<Line> theLines = ReadFileApplication.parseFile("drawingTest.csv");
Vector<Line> theLines = ReadFileApplication.parseFile("src/lab13_streams/data/drawingTest.csv");
// Display what we read
ReadFileApplication.displayLines(theLines);