방 #, 숙박 인 수, 체류 기간 및 1 박 1 인당 가격에 대한 매개 변수가있는 호텔에서의 최종 청구서를 제공하는 프로그램을 작성 중입니다.주 메소드가 클래스 문자열을 잘못 표시합니까?
그러나 BBRoom 클래스에서는 수학이 정확하지만 클래스 매개 변수의 정보를 처리하지는 않습니다.
드라이버 클래스 :
public class BedAndBreakfastDriver {
public static void main(String[] args) {
//float price, int rmNum, int numOccupants, int duration
//or
//int rmNum, int numOccupants, int duration, float price
BBRoom Smith;
Smith = new BBRoom(29.95, 16, 1, 5);
System.out.println(Smith);
}
}
BBRoom 클래스 : 어떤 이유
public class BBRoom {
final int MAXCAP = 4;
final int MINCAP = 1;
final int MINSTAY = 1;
int room;
int persons;
int nights;
double cost;
double surcharge;
double cleanUp;
double cottageCost;
NumberFormat fmt1 = NumberFormat.getCurrencyInstance();
BBRoom(double price, int rmNum, int numOccupants, int duration){}
BBRoom(int rmNum, int numOccupants, int duration, double price){}
private int getRoomNumber(int rmNum){
room = rmNum;
return room;
}
private int getPersons(int numOccupants){
if (numOccupants < MINCAP){
persons = MINCAP;
}if(numOccupants > MAXCAP){
persons = MAXCAP;
}else{
persons = numOccupants;
}
return persons;
}
private int getNights(int duration){
if(duration < MINSTAY){
nights = MINSTAY;
}else{
nights = duration;
}
return nights;
}
private double setCost(double price){
return price;
}
private double getCost(double price){
if (persons < 2){
cost = price*2*nights;
}else{
cost = (persons*price*nights);
}
return cost;
}
private double BBCottage(double cost){
surcharge = (12.95*nights);
cleanUp = 47.99;
cottageCost = cost+surcharge+cleanUp;
return cottageCost;
}
public String toString(){
String bill = ("Room Number"+room+" "+"Guests:"+persons+" "+"Nights:"+nights+" "+"Basic Package:"+ fmt1.format(cost)+" "+"Cottage Upgrade:"+fmt1.format(cottageCost));
return bill;
}
}
내가
"룸 등 모든 변수를 표시하는 출력을 점점 계속 : 0 손님 : 0 박 : 0 기본 패키지 : 0.00 코티지 업 그레 이드 : 0.00 "
도움이 될 것입니다. 감사!
P. BBCottage 메서드를 하위 클래스로 변환하는 것을 선호하지만이를 수행하는 방법을 잘 모르겠습니다. 내가 그것에 대한 지침을 얻을 수 있다면 좋을 것입니다!
을합니까? 제정신 인 사람은 아무 것도하지 않고 무엇인가를하는 함수 호출을 어떻게 기대합니까? – hexafraction