Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit



CSCI 310       Software Engineering

PROJECT 1a

Overview: Software development tools are important in practice. During the lecture, we discussed Git (for version control), Ant (for building), and JUnit (for unit testing). For this project, you must use these tools while developing a Java program. We suggest that you use test-driven development (TDD) which requires you to write tests before writing the code.

Objective: The objective is to gain experience in using software development tools, as well as test- driven development.

Detailed Description: You must develop a Java program that implements a Searchable Flight Map. First, the Java program needs to be able to read from a text file, and write to another text file. The input text file is expected to store a flight map annotated with flying costs and an origin city.  Your program must determine the route to each city that can be reached from the origin city and the associated total cost. Your program must also write, to the output text file, the flight route from the origin city to each reachable city and the associated total cost.

Consider the following flight map as an example:

 

 

In  this  map,  letters  represent  cities,  arrows  represent  direct  flights  between  cities,  and  dollar amounts written beside the arrows indicate the associated flying costs.  For  example, there is a direct flight from city P to city W and the cost of this direct flight is $200.

Given such a map, we say that the city B can be visited from the city A if there exists a route (a sequence of direct flights) from A to B. For example, the cities R, X, W, S, T, Y, and Z can be visited from the city P, whereas the city Q cannot be visited from the city P. The set of cities that lie in the flight route from P to Z is: P, W, Y, and Z.


Given a pair of cities (A, B) where B can be visited from A, we define the total cost for flying from A to B as the sum of all direct flight costs in a route from A to B. For example, the total cost from P to Z

(route: P, W, Y, Z) is $200 + $500 + $450 = $1150.

Your program should be invoked as follows:

java   SearchMap   input_file    output_file

The format of the input file is as follows:

inputfile.txt

P

P W 200

P R 300

R X 200

Q X 375

W S 250

S T 300

T W 350

W Y 500

Y Z 450

Y R 600

The file inputfile.txt contains a description of the origin city (P) and a cost-annotated flight map (see  the  figure  on  Page  1).  The  first  line  of the  file  contains  the  name  of the  origin  city.  Each subsequent  line  describes  a  pair  of  cities  that  has  a  direct  flight  and  the  associated  cost.  For example, the second line indicates that the cost of the direct flight from P to W is $200.

The  file  outputfile.txt  shown  below  contains  the  expected  output  where  each  line  displays  a (destination) city that can be visited from the origin city, the route, and the total cost.

outputfile.txt

Destination

R

X

W

S

T

Y

Z

Flight Route from P P, R

P, R, X

P, W

P, W, S

P, W, S, T

P, W, Y

P, W, Y, Z

Total Cost $300           $500           $200           $450           $750           $700           $1150

Assumptions: You can assume that only a single character will be used to represent a city. You

should not make any assumption on the total number of cities or direct flights between pairs of cities that the flight map will have.

If multiple routes exist to a destination city, you need to output at least one route (you do not need to output all the possible routes, and you do not need to output the shortest route).


What to hand in: After your project is completed, create a (single) ZIP file containing the entire project directory (named “Project1a”), and upload the ZIP file to the course website on Blackboard.  While submitting your project, please make sure to include, in the (single) ZIP file, everything that is needed to compile and run your code on another computer. This will affect how your project is

graded: after downloading your ZIP file from Blackboard to another computer, the teaching staff must be able to run your code.

Directory Structure: Your “Project1a” directory should have the following content:

 Project1a/build.xml - Written by you: Ant’s build script
 Project1a/src - Written by you: Java source files of the form *.java
 Project1a/bin - Generated: Java class files (generated by javac via Ant)
 Project1a/dist - Generated: a Jar file (generated by jar via Ant)
 Project1a/doc- Generated: HTML documentation (generated by javadoc via Ant)
 Project1a/.git - Generated: Git local repository (generated by git init or git clone)
 Project1a/.gitignore - Written by you: a configuration file for Git



In addition to the Git repository on your computer (Project1a/.git), you are strongly encouraged to use GitHub or Bitbucket to host a remote Git repository, and frequently synchronize by using “git push” and “git pull”. This is important (and is solely for your own benefit) because, should anything happened to your local computer, there is always a remote backup that you can rely on.

You must keep your remote Git repository on GitHub/Bitbucket private. Failing to do so will be deemed violation of honor code.

Java  Source  File  Naming  Convention:  The  Java  source  files  in  “Project1a/src”  must  include SearchMap.java and FlightMap.java, together with other Java source files that you may create.

For  each Java source file that you  create, there should be a corresponding Java  source file that implements the JUnit tests.  For example, the testing files for SearchMap.java and FlightMap.java could be named TestSearchMap.java and TestFlightMap.java, respectively.

The file SearchMap.java contains the “client” code – the main function that handles command-line options and file read and write -- that uses a FlightMap.

The FlightMap class, implemented in FlightMap.java, stores a map and provides operations that facilitate a search of the map. Feel free to implement FlightMap in any way you like.

 

Grading: The assignment will be graded out of a maximum of 100 points.

      20 points will be based on your use of Git during the development:

o (a) you need to put “build.xml” and “src/*.java” under version control (5 points);

o (b) you need to use “.gitignore” to exclude files you don’t want to track (5 points);

o (c) you need to commit to the Git repository frequently and write meaningful commit message during the development (10 points).

      40 points will be based on your use ofAnt during the development:

o (a) Running “ant init” should create the “bin/dist/doc” directories (5 points);


o (b) Running “ant clean” should delete the “bin/dist/doc” directories (5 points);

o (c) Running “ant compile” should compile “src/*.java” to “bin/*.class” (5 points);

o (d) Running “ant dist” should transform “bin/*.class” to a jar file in “dist” (5 points);

o (e) Running “ant doc” should generate HTML files in the “doc” directory (10 points);

      Every  method  in  every  class  of your  production  code  must  have  meaningful comments

      Your jUnit test code, in contrast, does not need to be processed by “ant doc”

o (f) Running “ant test” should run the JUnit tests you’ve written (10 points).

      Every method in every class  of your production code must be tested at least once.

      40 points will be based on whether your Java program is implemented correctly:

o (a)  If your  entire  program  works  as  expected,  i.e.,  it  can  read  from  input  text  file provided by the grader, compute the routes and associated costs correctly, and write the result to the output text file, you get all of the 40 points.

o (b) Otherwise, you may get partial credit:

      if your program can read from the input file and correctly display the flight map on screen (5 points);

      if your program can write the search result (regardless of its correctness) to the output file (5 points);

      if  your  program   cannot  perform   file   read/write  properly,  but   otherwise, implements the flight search correctly (20 points);

 

Partial  credit:  To  get  partial  credit,  you  must  turn  in  a  written  description  (PDF  file  named “Project1a/partialcredit.pdf”) that describes 1) the problems you encountered, 2) what parts of your program work correctly, and 3) suggestions to the grader on how your program may be tested for partial credit consideration.  Ifyour program runs, you don’t need to turn in such a file.

 

 

Honor  Code:    You  must  work  independently  on  this  assignment.  Please  review  the  related statement in the syllabus.