Question
import java.io.*; import java.util.*; // Class DelivA does the work for deliverable DelivA of the Prog340 public class DelivA { File inputFile; File outputFile; PrintWriter
import java.io.*;
import java.util.*;
// Class DelivA does the work for deliverable DelivA of the Prog340
public class DelivA {
File inputFile;
File outputFile;
PrintWriter output;
Graph g;
public DelivA( File in, Graph gr ) {
inputFile = in;
g = gr;
// Get output file name.
String inputFileName = inputFile.toString();
String baseFileName = inputFileName.substring( 0, inputFileName.length()-4 ); // Strip off ".txt"
String outputFileName = baseFileName.concat( "_out.txt" );
outputFile = new File( outputFileName );
if ( outputFile.exists() ) { // For retests
outputFile.delete();
}
try {
output = new PrintWriter(outputFile);
}
catch (Exception x ) {
System.err.format("Exception: %s%n", x);
System.exit(0);
}
System.out.println( "DelivA: To be implemented");
output.println( "DelivA: To be implemented");
output.flush();
}
}
ICS 340 Programming Project, Deliverable A Specification: Start with the given Java program "prog340", which lets you select a file to read from your computer, reads the file, and interprets that file as the specification of a graph.' Then enhance it to do the following: 1. Write code necessary to print out, for each Edge, the name of the Node from which the Edge emanates, the name of the Node at which the Edge terminates, and the label of the Edge, in the format listed below. The "prog340" handout describes the format of the input file for this and all program deliverables. As will always be the case in this class, the program must be written in Java and must run on the University Windows computer systems. Output: Here is sample output for one graph. val AAA Alfa Bravo 62 999 -42 3 Charlie 4 Delta 3 22 Echo yes DDD 99 E fig X 9 1-2 33 de The output for this file should be: Edge from Alpha to Bravo labeled > Kdge from Alpha to Delta labeled 99. Edge from Alpha to Echo labeled fig. Edge from Bravo to xlpha labeled 999. Kdge from bravo to Bravo labeled - 42. Edge from bravo to Charlie labeled 3. Edge from BRAVO to Delta Labeled x. Edge from Bravo to koho labelud - Edge from Charlie to havo labeled 4. Edge from Charlie to Delta labeled y. Kage from Charlie to Echo labeled 9. a University Windows computer systems. E Output: Here is sample output for one graph. val AAA BB Alfa X > Bravo 67 999 -42 3 Charlie 4 Delta 4e 3 22 X Echo yes fig DDD 99 x yz 9 1-2 33 de The output for this file should be: Edge from Alpha to Bravo labeled >. Edge from Alpha to Delta labeled 99. Edge from Alpha to Echo labeled fig. Edge from Bravo to Alpha labeled 999. Edge from Bravo to Bravo labeled -42. Edge from Bravo to Charlie labeled 3. Edge from Bravo to Delta labeled x. Edge from Bravo to Echo labeled Edge from Charlie to Bravo labeled 4. Edge from Charlie to Delta labeled yz. Edge from Charlie to Echo labeled 9. Edge from Delta to Alpha labeled 3. Edge from Delta to Bravo labeled 22. Edge from Delta to Charlie labeled x. Edge from Delta to Echo labeled 2 Edge from Echo to Delta labeled be. Edge from Echo to Echo labeled 33. The order in which the Edges print out is not important. See the 40 spring 2020.docx file for details a Programming Project There will be one multi-deliverable Java programming project this semester, which will be divided into three separately-graded program deliverables (DelivA through Delive). A specification for each deliverable will be uploaded to D2L. Each deliverable will build on past deliverables. Start from a Working Program Some Java programs work on student computers but not on University lab (Windows) computers or grading computer. So this semester, you are given an initial codebase, Prog340", that seems to compile and run on all platforms. It opens a menu for you to select an action. It has a number of predefined menu items describing the various actions (which you will implement during the semester). o When you start the program the first action you will want to take will be to read a file. The input files for all deliverables have the same, specified format. It allows you to continuously select actions as long as you wish o Including read another file. It allows you to exit the program. Each Deliverable will involve your modifying your existing program (DelivA involves modifying the initial program given to you). This minimizes any duplicate effort. But it means that if you screw up a deliverable, you may have screwed up another deliverable later in the course. . Grading Deliverable A is worth 25 points. It is pretty simple if you understand o programming in Java. For each of Deliverables B (50 pts) and C (55 pts): Correct functioning of the program is worth 40 and points (DelivB and DelivC). You will receive a set of test files which will be used to evaluate the program. Some other test files may also be used that are not given to you (in real life, you design to the specification, you can't test everything). You will receive the desired output for at least one test file. Part of learning the material in the class is figuring out the correct answer to the test files yourself. The correctness points are divided among the tests. For instance, if there are 8 tests, each test is worth 10 points. Normally, a test is either all or nothing. Oor max points, but you can get substantial partial credit for output whose content is correct, but whose formatting is off For Deliverable C, there will be a report worth 5 points. Program Architecture The initial program reads a text file and interprets it as a graph. Input File All the input files in this course will look something like this file AB0.txt. Note that all columns of data are separated by I or more spaces (not tabs): I I ICS 340 Spring 2021 C val x 67 DDD E 99 fig 999 BB > -42 4 22 Alfa Bravo Charlie Delta Echo 3 ya 3 4e yes 9 !-2 de 33 . The first row is a header row. The first "" is merely a placeholder. All files will have this at the beginning of the header row. o "val" is a column label for the column of node values The rest of the strings are mnemonies for the nodes of the graph. They are alphanumerie and do not contain spaces Each subsequent row describes one node and its outgoing edges. The first column contains the name of the node (eg, "Alfa") The string in the "val" column is the value of the node, which may be numere, but which will certainly always consist of a string of printable characters. The character by itself stands for "no value. (e.g., node "Charlie" has no value.) For the rest of the columns, if there is no edge going from the node to another node, there is a "** in the appropriate column. (eg, there is no edge from node "Charlie" to node "Alfa") O not contain spaces. Each subsequent row describes one node and its outgoing edges. The first column contains the name of the node (e.g., "Alfa") The string in the "val" column is the value of the node, which may be numeric, but which will certainly always consist of a string of printable characters. The character "_" by itself stands for "no value". (e.g., node "Charlie" has no value.) o For the rest of the columns, if there is no edge going from the node to another node, there is a su in the appropriate column. (e.g., there is no edge from node "Charlie" to node "Alfa") o If there is anything else in that column, that is the label of the edge. For some deliverables, this will be numeric, for others it may not be. Note that self-edges are allowed. If you like a picture of what this is, here's what the above table locks like in graphical form: Eiche AM Alfa DOO De L Chwi Prog340 is the main class, which handles the I/O. Graph is a class whose objects represent graphs. Node is a class whose objects represent nodes (a.k.a., vertices) in the graph. Edge is a class whose objects represent edges (a.k.a., arcs) between nodes of the graph. Note that each edge has a direction. It goes from one specific node to another specific node. Here is a basic UML class diagram for these four classes. All methods and attributes are listed explicitly rather than using composition connectors, to be easily understood by people with little UML background. Prog340 Graph File inputFile ArrayList
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started