Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Logic In Databases International Workshop Lid 96 San Miniato Italy July 1 2 1996 Proceedings Lncs 1154

Authors: Dino Pedreschi ,Carlo Zaniolo

1st Edition

3540618147, 978-3540618140

More Books

Students also viewed these Databases questions

Question

=+ Is the needed level available from outside sources?

Answered: 1 week ago