题目存储在上传的文件当中。

  • 代码实现

Subway 类:

 package ClassroomTest;

 public class Subway {

     private String railway;
private String station[];
private String information; public String getRailway() {
return railway;
} public void setRailway(String railway) {
this.railway = railway;
} public String[] getStation() {
return station;
} public Subway() {
super();
this.railway = railway;
this.station = station;
this.information = information;
} public void setStation(String[] station) {
this.station = station;
} public String getInformation() {
return information;
} public void setInformation(String information) {
this.information = information;
} }

SubwayManger 类

 package ClassroomTest;
/*
* 信1805-2
* 20183547
* 崔星宇
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner; public class SubwayManager {
static Scanner sc=new Scanner(System.in); public static void main(String[] args) throws IOException {
Subway first=new Subway();
Subway third=new Subway();
String []b1=new String[30];
String []b2=new String[10];
File file=new File("D://百度网盘//shijiazhuang-subway.txt");
InputStream in=new FileInputStream(file); //实例化FileInputStream
byte b[]=new byte[1024];
int len=in.read(b);
in.read(b);
in.close(); //关闭输入流
String d=new String(b,0,len);
String[] words = d.split(" ");
first.setRailway(words[0]);
first.setInformation(words[21]);
int j=0;
for(int i=1;i<21;i++) {
b1[j++]=words[i];
}
third.setRailway(words[22]);
third.setInformation(words[29]);
j=0;
for(int i=23;i<29;i++) {
b2[j++]=words[i];
}
third.setStation(b2);
System.out.println("***************************************************************");
System.out.println(" 欢迎乘坐石家庄地铁 ");
System.out.println("****************************************************************");
System.out.println(" 1、 显示具体线路信息; ");
System.out.println(" 2、 购票 ");
System.out.println("****************************************************************");
int a;
sc=new Scanner(System.in);
a=sc.nextInt();
// 线路图
if(a==1) {
System.out.println("请选择需要查找的线路:");
System.out.println("0 :全部 ");
System.out.println("1:一号线 ");
System.out.println("2:三号线 ");
sc=new Scanner(System.in);
int b11=sc.nextInt();
System.out.println("***************************************************************");
System.out.println(" 石家庄地铁线路图 ");
System.out.println("***************************************************************");
int i=0;
j=0;
if(b11==1)
{ i=0;
System.out.print("1号线:");
while(b1[i]!=null) {
System.out.print(b1[i]+" ");
i++;
}
System.out.println();
}
/*else*/ if(b11==2) {
System.out.print("3号线:");
j=0;
while(b2[j]!=null) {
System.out.print(b2[j]+" ");
j++;
}
System.out.println();
}
if(b11!=1&&b11!=2){
System.out.println("1号线:");
i=0;
while(b1[i]!=null) {
System.out.print(b1[i]+" ");
i++;
}
System.out.println();
System.out.println("3号线:");
j=0;
while(b2[j]!=null) {
System.out.print(b2[j]+" ");
j++;
}
System.out.println();
}
System.out.println("***************************************************************");
}
//购票
else {
System.out.println("****************************************************************");
System.out.println(" 欢迎乘坐石家庄地铁 ");
System.out.println("****************************************************************");
System.out.println(" 起始站:");
System.out.println(" 终点站:");
System.out.println(" 购票数量:");
System.out.println("****************************************************************");
sc=new Scanner(System.in);
String a1=null;
String a2=null;
int number=0;
a1=sc.next();
a2=sc.next();
number=sc.nextInt();
int address1=0,address2=0;
int address3=0,address4=0;
int number1=0,number2=0;
int number3=0,number4=0;
int price=0;
int mail=0;
int i = 0;
int k1=0;
int k2=0;
while(b1[i]!=null) {
if(b1[i].compareTo(a1)==0) {
address1=i;
k1++;
}
if(b1[i].compareTo(a2)==0) {
address2=i;
k1++;
}
i++;
}
i=0;
while(b2[i]!=null) {
if(b2[i].compareTo(a1)==0) {
address3=i;
}
if(b2[i].compareTo(a2)==0) {
address4=i;
}
i++;
}
//全在一号线
if(k1==2) {
k2=Math.abs(address2-address1);
if(k2<=3) {
price=1;
}
else {
int k=0;
if(k2%3==0) {
k=0;
}else {
k=1;
}
price=k2/3+k;
}
if(address1>address2)
{
int temp=address1;
address1=address2;
address2=temp;
}
System.out.println("***************************************************************");
System.out.println(" 欢迎乘坐石家庄地铁 ");
System.out.println("****************************************************************");
System.out.println(k2+"站");
for(int i1=address1;i1<=address2;i1++) {
System.out.println(b1[i1]);
}
System.out.println("购票单价:"+price+"元");
System.out.println("购票金额:"+price*number+"元");
}
String station="新百广场";
//全在三号线 或者 一个在新百广场 一个在三号线 k1=1 一个站点在三号线上 另一个在新百广场或者一号线其他位置
if(k1==0||(k1==1&&(a1.compareTo(station)==0||a2.compareTo(station)==0))) {
k2=Math.abs(address3-address4);
if(k2<=3) {
price=1;
}else {
int k=0;
if(k2%3==0) {
k=0;
}else {
k=1;
}
price=k2/3+k;
}
if(address3>address4)
{
int temp=address3;
address3=address2;
address4=temp;
}
System.out.println("***************************************************************");
System.out.println(" 欢迎乘坐石家庄地铁 ");
System.out.println("****************************************************************");
System.out.println(k2+"站");
for(int i1=address3;i1<=address4;i1++) {
System.out.println(b2[i1]);
}
System.out.println("购票单价:"+price+"元");
System.out.println("购票金额:"+price*number+"元");
}
//换乘 一个在三号线且另一个不在新百广场
if(k1==1&&a1.compareTo(station)!=0&&a2.compareTo(station)!=0) {
if(address2!=0) {
address1=address2;
}
if(address4!=0) {
address3=address4;
}
int k21=0;
int k22=0;
k21=Math.abs(address1-14);
k22=Math.abs(address3-1);
k2=k21+k22;
if(k2<=3) {
price=1;
}else {
int k=0;
if(k2%3==0) {
k=0;
}else {
k=1;
}
price=k2/3+k;
}
System.out.println("***************************************************************");
System.out.println(" 欢迎乘坐石家庄地铁 ");
System.out.println("****************************************************************");
System.out.println(k2+"站");
if(address1<14) {
for(int i1=address1;i1<15;i1++)
System.out.println(b1[i1]);
}else {
for(int i1=address1;i1>13;i1--) {
System.out.println(b1[i1]);
}
}
System.out.println("(换乘站)");
if(address3<1) {
for(int i1=address3;i1<1;i1++) {
System.out.println(b2[i1]);
}
}else {
for(int i1=address3;i1>1;i1--) {
System.out.println(b2[i1]);
}
}
System.out.println("购票单价:"+price+"元");
System.out.println("购票金额:"+price*number+"元");
}
}
}
}

测试结果当只在一号线或者旨在三号线的时候没有问题,对于换线的情况,从左到右没有任何问题,如果顺序不按照从左到右,输出结果会出现混乱(顺序不正确),除此之外,在录入信息的时候会出现错误,没有解决。

  • 设计思路

该系统主要分为查询线路与订购车票两个功能,两个功能不会同时运行,即可同时分为两组情况,每种情况分别输出,对于线路查询没有问题,对于订购车票(并输出线路与价格,还有站点的计算问题),首先把简单的一条线路的情况写出来,除此之外,我认为

对于其中的特殊点换乘站点要去去除特殊化,将其平凡化处理,对于换乘路线要避免换乘点的重复相加。站点的计算不计算起始站点,记录下车站点。

2019.9.30极限测试 04.JAVA语言课堂测试试卷-极限测试的更多相关文章

  1. 【Java 语言生态篇】Junit 测试单元

    01 概述   JUnit是一个由 Erich Gamma 和 Kent Beck 编写的一个回归测试框架(regression testing framework).Junit测试是白盒测试.JUn ...

  2. JAVA语言课堂测试源代码及使用截图

    1源代码 第一部分 package 开学测试.java;class ScoreInformation {String stunumber;String name;double mathematicss ...

  3. 【JAVA基础】04 Java语言基础:方法

    1. 方法概述和格式说明 为什么要有方法 提高代码的复用性 什么是方法 完成特定功能的代码块. 方法的格式 修饰符 返回值类型 方法名(参数类型 参数名1,参数类型 参数名2...) {     方法 ...

  4. JAVA语言课堂测试01源代码(学生成绩管理系统)

    package 考试; /*信1807-8 * 20183798 * 向瑜 */ import java.util.Scanner; //ScoreInformation 类 class ScoreI ...

  5. java语言课堂动手动脑

    1 运行 TestInherits.java 示例,观察输出,注意总结父类与子类之间构造方法的调用关系修改Parent构造方法的代码,显式调用GrandParent的另一个构造函数,注意这句调用代码是 ...

  6. Tars | 第3篇 Tars中期汇报测试文档(Java语言实现Subset路由规则)

    目录 前言 1. 任务介绍 2. 测试模拟方案 2.0 *前置工作 2.1 添加路由规则 2.2 添加存活节点 2.3 [输出]遍历输出当前存活节点 2.4 [核心]对存活节点按subset规则过滤 ...

  7. 【Java初探实例篇01】——Java语言基础

    示例系列,将对每节知识辅以实际代码示例,通过代码实际编写,来深入学习和巩固学习的知识点. IDE:intellij IDEA: 语言:Java 本次示例:Java语言基础知识的应用. 创建包day_4 ...

  8. 测试的Python、 Java语言之争

    现在测试行业如果不会开发语言的话是很难找到工作的,即使是一些功能测试的岗位也会要求代码语言作为技术储备,因为如果做自动化测试或者测试工具脚本开发或者接口测试等都离不开开发语言,那作为测试如果没有代码经 ...

  9. 2019 Android 高级面试题总结 从java语言到AIDL使用与原理

    说下你所知道的设计模式与使用场景 a.建造者模式: 将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示. 使用场景比如最常见的AlertDialog,拿我们开发过程中举例,比如C ...

随机推荐

  1. sourcetree的安装

    参考博文: SourceTree安装教程和GitLab配置详解 关于Atlassian无法注册的问题 SourceTree跳过Atlassian账号,免登陆,跳过初始设置 sourcetree跳过注册 ...

  2. 06 MySQL运算符

    算数运算符     +    -    *    /    DIV    %    MOD   比较运算符     =    <>    !=    <=>(安全等于,NULL ...

  3. 觉醒 闭包/this

    两条非常重要的知识点 首先上题 var a = '322' var preview = function() { var a = '123' console.log(a, this, this.a) ...

  4. RadioGroup的使用

    前言: 使用RadioGroup就可以在选择情况多的时候,简化代码 RadioGroup 使用互斥选择时,会使用RadioGroup标签下面RadioButton,如下面的代码:(这样写下来,男和女的 ...

  5. HDU - 6201 transaction transaction transaction(spfa求最长路)

    题意:有n个点,n-1条边的无向图,已知每个点书的售价,以及在边上行走的路费,问任选两个点作为起点和终点,能获得的最大利益是多少. 分析: 1.从某个结点出发,首先需要在该结点a花费price[a]买 ...

  6. arduino通信问题的学习与解决

    我想实现的是,我用电脑在串口监视器上输入一个字符串,arduino能识别这个字符串中的每一个字符并在相应的串口上给出相应的高低电平以驱动舵机,比如输入L1,RS,功能是左手腕舵机逆时针旋转90°,然后 ...

  7. grep -w ,grep -e的使用

    1.grep -w -wDoes a word search.grep -w用于字符串精确匹配若文件中的内容包括如下:262 a326226如果 grep ‘26’ file,结果是三行全部都被显示若 ...

  8. 全选checkbox只能执行一次的问题

    现象:第一次运行,点select all那个checkbox,可以全选,再点一次,也可以全部取消.但是,之后不管怎样点击,都没有用了…… <input type="checkbox&q ...

  9. 127个常用的JS代码片段,每段代码花30秒就能看懂(上)

    127个常用的JS代码片段,每段代码花30秒就能看懂(上) JavaScript 是目前最流行的编程语言之一,正如大多数人所说:“如果你想学一门编程语言,请学JavaScript.” FreeCode ...

  10. 自己安装windows版本的Flink

    参照 https://blog.csdn.net/clj198606061111/article/details/99694033 我自己做一遍 找到对应的网址 https://flink.apach ...