问题描述
- Java程序求救,想不到怎么修改
-
(有四个class)
(这是某一个,叫它“A")public ParkingTicket issueParkingTicket() { ParkingTicket parkingTicket1 = new ParkingTicket(); if (isParkingTimeExpired()) { parkingTicket1 = new ParkingTicket(getOfficerName(),getBadgeNumber(), parkedCar.getLicenseNumber(),parkedCar.getCarMake(),parkedCar.getCarModel(), calculateFine()); parkingTicket1.displayDeatils (); } else { return null; } return parkingTicket1; }
(这是另一个,叫它“B”)
(NUMBER_PART = 1001)private String TicketNumber() { ticketNumber = "V" + NUMBER_PART; NUMBER_PART++; return ticketNumber; }
就是当我用public ParkingTicket issueParkingTicket()打印出"B"中的信息时,ticketNumber就会变成1003,1006,1009,每次都是加3而不是加1。但我直接用"B”打印信息的时候,ticketNumber就正常每次加1。这是为什么呢?
"A"是拿了其他两个Class输入的东西和本身输入的东西,传过去"B"那里。我用的是BlueJ
时间: 2024-12-06 04:38:06