公交车票系统的付款和打印收据部分

时间:2019-03-16 05:15:14

标签: java oop

我必须完成项目的最后一部分,即付款和收据部分。我仍然不知道如何付款,但是我确实尝试过打印收据部分。我正在使用Netbeans 8.2。下面的代码是我的打印收据代码,它可以成功构建,但是没有任何输出。也许是因为我必须先编译所有其他代码,例如座位号,日期,时间等才能打印出来?不知道原因是否是因为我没有将主要部分留空,但我不知道在那放什么。

我是一名初学者,但还有很长的路要走。我会尽力理解您的解释。先感谢您。

import java.util.Date;
import java.util.Scanner;

public class BusPaymentDetails {

    public static void main(String[] args) {

    }


class  Printpaymentdetails { 

       public void Printpaymentdetails () {

        Date timenow = new Date();
        Scanner ticket = new Scanner(System.in);

        System.out.println("Your Bus E-Ticket: ");

        String date = ticket.nextLine(); 
        System.out.println("Date: " + timenow.toString());  

        String deptime = ticket.nextLine(); 
        System.out.println("Time of departure: " + deptime);

        String arrtime = ticket.nextLine();
        System.out.println("Time of arrival: " + arrtime);

        String place = ticket.nextLine();
        System.out.println("Trip to: " + place);

        String buscompany = ticket.nextLine();
        System.out.println("Bus Company: " + buscompany);

        int seatnumber = ticket.nextInt();
        System.out.println("Seat number: " + seatnumber);

        double price = ticket.nextDouble();
        System.out.println("Price:  " + price);

        System.out.println("This ticket is non-refundable.");
        System.out.println("Please be courteous and do not smoke. Enjoy your trip.");   
       }
}
}

1 个答案:

答案 0 :(得分:2)

运行Java代码时,您正在调用<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script> <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" /> <select class="select2-container"></select>方法,此处该方法为空,因此未运行任何操作。您必须在此方法的主体中添加一些内容:

main