You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.0 KiB
31 lines
1.0 KiB
package hs.fulda.de.ci.exam.project;
|
|
|
|
import java.io.*;
|
|
import java.util.Scanner;
|
|
|
|
public class AircraftRepository {
|
|
|
|
boolean save(Aircraft aircraft) throws IOException {
|
|
FileWriter fw = new FileWriter("aircraft_list.txt", true);
|
|
BufferedWriter bw = new BufferedWriter(fw);
|
|
bw.write(aircraft.toString());
|
|
bw.newLine();
|
|
bw.close();
|
|
return true;
|
|
};
|
|
String findAircraftByAircraftName(String AircraftName){
|
|
File file = new File("aircraft_list.txt");
|
|
try {
|
|
Scanner scanner = new Scanner(file);
|
|
while (scanner.hasNextLine()) {
|
|
String line = scanner.nextLine();
|
|
if(line.matches("(.*)"+AircraftName+"(.*)")) {
|
|
return line;
|
|
}
|
|
}
|
|
} catch(FileNotFoundException e) {
|
|
System.out.println("There are no aircrafts added yet. Please add a aircraft first");
|
|
}
|
|
return "";
|
|
}
|
|
}
|