Commit c68f1fa7 authored by Yakshit Jain's avatar Yakshit Jain
Browse files

Module-6

parent 2cae0f6c
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -18,31 +18,24 @@ import java.util.List;
import java.util.stream.Collectors;
public class App {
public String getGreeting() {
return "Hello World!";
}
public static void main(String[] args) throws NoSuchDataException {
public static void run(List<String> commandLineArgs){
ApplicationConfig applicationConfig = new ApplicationConfig();
DataLoader dataLoader = applicationConfig.getDataLoader();
CommandInvoker commandInvoker = applicationConfig.getCommandInvoker();
BufferedReader reader;
List<String> commandLineArgs = new LinkedList<>(Arrays.asList(args));
String expectedSequence = "INPUT-FILE$CINEMA-DATA$SCREEN-DATA$SEAT-DATA$CUSTOMER-DATA$MOVIE-DATA$SHOW-DATA";
String actualSequence = commandLineArgs.stream()
.map(a -> a.split("=")[0])
.collect(Collectors.joining("$"));
if(expectedSequence.equals(actualSequence)){
String inputFile = commandLineArgs.get(0).split("=")[1];
commandLineArgs.remove(0);
for(String arg: commandLineArgs){
String[] splits = arg.split("=");
try {
dataLoader.executeData(splits[0],splits[1]);
} catch (NoSuchDataException e) {
e.printStackTrace();
}
}
BufferedReader reader;
try {
reader = new BufferedReader(new FileReader(args[0].split("=")[1]));
reader = new BufferedReader(new FileReader(inputFile));
String line = reader.readLine();
while (line != null) {
List<String> tokens = Arrays.asList(line.split(" "));
......@@ -55,5 +48,15 @@ public class App {
e.printStackTrace();
}
}
public static void main(String[] args){
List<String> commandLineArgs = new LinkedList<>(Arrays.asList(args));
String expectedSequence = "INPUT-FILE$CINEMA-DATA$SCREEN-DATA$SEAT-DATA$CUSTOMER-DATA$MOVIE-DATA$SHOW-DATA";
String actualSequence = commandLineArgs.stream()
.map(a -> a.split("=")[0])
.collect(Collectors.joining("$"));
if(expectedSequence.equals(actualSequence)){
run(commandLineArgs);
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment