Question: import java.io . IOException; import java.util.List; public class MasterControl { static ScannerWrapper scannerWrapper = ScannerWrapper.getInstance ( ) ; static SystemWrapper systemWrapper = SystemWrapper.getInstance ( )

import java.io.IOException;
import java.util.List;
public class MasterControl {
static ScannerWrapper scannerWrapper = ScannerWrapper.getInstance();
static SystemWrapper systemWrapper = SystemWrapper.getInstance();
List read = null;
public static void main(String[] args){
MasterControl masterControl = new MasterControl();
try {
masterControl.start(scannerWrapper, systemWrapper);
} catch (IOException e){
throw new RuntimeException(e);
}
}
public void start(ScannerWrapper scannerWrapper, SystemWrapper systemWrapper){
Input input;
Output output;
try {
System.out.println("Enter 1 to read from console or 2 to read from file:");
int choice = Integer.parseInt(System.console().readLine());
if (choice ==1){
input = new InputFromConsole();
} else if (choice ==2){
input = new InputFromFile();
} else {
throw new IllegalArgumentException("Invalid choice");
}
CircularShifter circularShifter = new CircularShifter();
Alphabetizer alphabetizer = new Alphabetizer();
System.out.println("Enter 1 to write to console or 2 to write to file:");
choice = Integer.parseInt(System.console().readLine());
if (choice ==1){
output = new OutputToConsole(MasterControl.systemWrapper);
} else if (choice ==2){
output = new OutputToFile();
} else {
throw new IllegalArgumentException("Invalid choice");
}
read = input.read();
List shift = circularShifter.shiftLines(read);
List sort = alphabetizer.sort(shift);
output.write(sort);
} catch (IOException e){
e.printStackTrace();
}
}
}
C:\Users\slash\IdeaProjects\Week 4\src\main\java\MasterControl.java:15:11
java: exception java.io.IOException is never thrown in body of corresponding try statement
C:\Users\slash\IdeaProjects\Week 4\src\main\java\MasterControl.java:57:11
java: exception java.io.IOException is never thrown in body of corresponding try statement

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!