Pre-training individual projects (Metro Line)
1. Demand
Requirement 1
user can start the program from the command line. When the program starts, it reads the command line parameters corresponding to different commands. For information subway map, we agreed to adopt it as a parameter -map flag. It is necessary to obtain a corresponding custom file metro (designated subway.txt) -map parameters by reading the program starts, to obtain information subway map. An example of a calling application is as follows:java subway -map subway.txt
2 demand
in the application needs to support a new command-line argument -a, which specifies a user want to query subway lines. Thus, at a given subway line, you need to be able to start the program from the start line of the site, all sites sequentially output through the metro line until the terminus. We use the output file -o command-line arguments. An example of a calling application is as follows:java subway -a 1号线 -map subway.txt -o station.txt
Demand 3
If you want to take the subway, he hopes to pass the minimum number of stations to reach the destination from the starting point, so that you can add to two subway stations -b parameter name on the command line are used as starting with the purpose, such as the user wants to know Honghu the shortest route between the inside Fuxing Road, what, he can use the following command to let the program will result in a write routine.txtjava subway -b Honghuli Fuxing Road -map subway.txt -o routine.txt
2. Complete results
abstraction
Line, you can change to the site, general site
Problem-solving ideas
The whole task is divided into three parts: 1 from the departure site can transfer back to find the nearest site.
2. Wang Qianmian can find the nearest site from the end of the transfer
3. Each site configuration, while the two transfer Common sites between the number of sites viewed weight, the shortest path
Involved in class
The class name | Features |
---|---|
GetStation | Transfer station to obtain initial and final transfer station |
FileOperate | Get the file contents |
FloydInGraph | The shortest path between the transfer station |
Relative | Analytical relationship |
ShowPath | An intermediate transfer path |
FileOperateOp | Methods to achieve |
Subway | Total Control |
The relationship between modules
Reflection
- Do too little work in task analysis stage, the lack of experience in project development
- A high degree of coupling between the modules
- Many local code redundancy
- Not tested
- A bug in some places
reward
- I know a lot of learning tools
- Thinking is more open than before