Вчера я опубликовал вопрос о том, что ArrayList не печатает выходные данные методов, это просто ошибка синтаксиса. Сегодня, однако, я сталкиваюсь с подобной проблемой с исправленной ошибкой. Буду признателен, если кто-нибудь скажет мне, что не так с этим кодом.
Моя проблема в том, что ArrayList печатает [0.0, 0.0, 2.75] в отличие от списка цен, который я ожидал.
import java.util.ArrayList;
public class TransitCalculatorTwo {
int numberDays;
int numberRides;
int numberPlanSeven;
int numberPlanThirty;
double totalPriceSeven;
double totalPriceThirty;
double pricePerRideSeven;
double pricePerRideThirty;
double SinglePrice = 2.75;
double sevenDayPrice = 33.0;
double thirtyDayPrice = 127.00;
public int numberPlanSeven(int numberDays) {
int planSeven = (int) Math.ceil (numberDays / 7.0);
return planSeven;
}
public int numberPlanThirty(int numberDays) {
int planThirty = (int) Math.ceil (numberDays / 30.0);
return planThirty;
}
public double totalPriceSeven (int numberPlanSeven, double sevenDayPrice) {
double totalSeven = numberPlanSeven * sevenDayPrice;
return totalSeven;
}
public double totalPriceThirty (int numberPlanThirty, double thirtyDayPrice) {
double totalThirty = numberPlanThirty * thirtyDayPrice;
return totalThirty;
}
public double pricePerRideSeven (double totalPriceSeven, int numberRides) {
double ppRideSeven = totalPriceSeven / numberRides;
return ppRideSeven;
}
public double pricePerRideThirty (double totalPriceThirty, int numberRides) {
double ppRideThirty = totalPriceThirty / numberRides;
return ppRideThirty;
}
public ArrayList<Double> comparePrice() {
ArrayList<Double> prices = new ArrayList<Double>(); for (int i=0; i<1; i++) {
prices.add(pricePerRideSeven);
prices.add(pricePerRideThirty);
prices.add(SinglePrice);
}
return prices;
}
public static void main (String[]args) {
TransitCalculatorTwo customer = new TransitCalculatorTwo();
customer.pricePerRideSeven(66.0, 50);
customer.pricePerRideThirty(127.00, 50);
System.out.println(customer.comparePrice());
}
}