java程序是否有有pe头吗_Java中执行TopPype方法后程序随机终止

在使用Soal.Out.PrtLnf()之后,我的Java程序终止;

我在代码中的一些地方放置了system.out.println,以确定它在哪里终止,并且它似乎在执行println之后立即终止。

package exercises;

import java.util.Scanner;

public class TrainSeatBookingApplication {

public static void main(String[] args) {

// TODO Auto-generated method stub

SeatType theSeatType;

FloorGrid floorType;

TrainWay aTrainWay = null;

TrainSmart aTrainSmart = null;

Seat customerSeat;

char planeSizeChoice;

char seatingArea;

char seatEconomyOrFirst;

char programBookingChoice;

Scanner scan = new Scanner(System.in);

System.out.println("Would you like to board a petite floor sized plane or a grande floor sized plane?");

planeSizeChoice = scan.next().charAt(0);

planeSizeChoice = Character.toUpperCase(planeSizeChoice);

if (planeSizeChoice == 'P') {

floorType = new PetiteFloorGrid();

floorType.initialiseFloorGrid();

System.out.println("Would you like to be in the middle, window or asile?");

seatingArea= scan.next().charAt(0);

seatingArea = Character.toUpperCase(seatingArea);

System.out.println("Would you like to be seated in first class or middle class?");

seatEconomyOrFirst = scan.next().charAt(0);

seatEconomyOrFirst = Character.toUpperCase(seatingArea);

System.out.println("Would you like your seat to be booked via the smart program or the way program?");

programBookingChoice = scan.next().charAt(0);

programBookingChoice = Character.toUpperCase(programBookingChoice);

if (seatEconomyOrFirst == 'F') {

if (programBookingChoice == 'S') {

customerSeat = aTrainSmart.reserveFirstClass(planeSizeChoice, SeatType.MIDDLE);

System.out.println(floorType);

}

else {

customerSeat = aTrainWay.reserveFirstClass(planeSizeChoice, SeatType.MIDDLE);

System.out.println(floorType);

}

}

}

else {

floorType = new GrandeFloorGrid();

floorType.initialiseFloorGrid();

System.out.println("Would you like to be in the middle, window or asile?");

seatingArea= scan.next().charAt(0);

seatingArea = Character.toUpperCase(seatingArea);

System.out.println("Would you like to be seated in first class or middle class?");

seatEconomyOrFirst = scan.next().charAt(0);

seatEconomyOrFirst = Character.toUpperCase(seatingArea);

System.out.println("Would you like your seat to be booked via the smart program or the way program?");

programBookingChoice = scan.next().charAt(0);

programBookingChoice = Character.toUpperCase(programBookingChoice);

System.out.println("Did not reach start of if");//testing program LINE57

if (seatEconomyOrFirst == 'F') {

if (programBookingChoice == 'S') {

customerSeat = aTrainSmart.reserveFirstClass(planeSizeChoice, SeatType.MIDDLE);

System.out.println(floorType);

}

else {

customerSeat = aTrainWay.reserveFirstClass(planeSizeChoice, SeatType.MIDDLE);

System.out.println(floorType);

}

//System.out.println("Did not go through either if or else");//testing program

}

}

}

}

我还有另外两行可以做完全相同的工作(但是保存到不同的变量中),它们工作得非常好。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值