class Acc {
String accNo; //계좌번호
String ownName; //예금주 이름
int bal; //잔액
Acc(String accNo, String ownName, int bal){
this.accNo=accNo;
this.ownName=ownName;
this.bal=bal;
}
void deposit(int amnt) {
bal+=amnt;
}
int withdraw(int amnt) throws Exception{
if(bal<amnt)
throw new Exception("잔액이 부족합니다.");
bal -=amnt;
return amnt;
}
}
class MinusAcc extends Acc{
int cred; // 마이너스 한도액
MinusAcc(String accNo, String ownName, int bal) {
super(accNo, ownName, bal);
}
@Override
int withdraw(int amnt) throws Exception {
if(bal+cred<amnt)
throw new Exception("인출이 불가능합니다.");
bal -=amnt;
return amnt;
}
}
public class accMain {
public static void main(String args[]) throws Exception {
MinusAcc obj = new MinusAcc();
obj.accNo = "000-11";
obj.ownName = "김선달";
obj.bal = 10;
obj.cred = 5000;
obj.withdraw(50);
try {
System.out.println("인출액:");
System.out.println("잔액:"+obj.bal);
System.out.println("마이너스 한도액:"+obj.cred);
} catch (Exception e){
System.out.println(e.getMessage());
}
}
}
C:\Users\pCm\IdeaProjects\untitled\src\accMain.java:38:24
java: constructor MinusAcc in class MinusAcc cannot be applied to given types;
required: java.lang.String,java.lang.String,int
found: no arguments
reason: actual and formal argument lists differ in length
상속, 생성자
초보라 그런데 설명 가능하심?
생성자에 인수가 필요한데 너는 아무것도 안넣음
MinusAcc obj = new MinusAcc(); 이거 말하시는거맞음
ㅇㅇ
ㅇㅎ 감사합니다
obj.withdraw(50);
여기서 int amnt 안쓰고 저 50 추출할수있나요?
뭔 소리임 그게
"인출액"+amnt 이렇게 하고 싶은데
어떻게 하나요?
아 생각 1초도 안했음 ㅈㅅ
덕분에 해결했습니다 ㄳ
"인출액"+amnt 이렇게 하고 싶은데