게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
자바 abstract 질문
게시물ID : programmer_18560짧은주소 복사하기
작성자 : 손블랙
추천 : 0
조회수 : 1012회
댓글수 : 1개
등록시간 : 2016/09/30 13:24:43
옵션
  • 본인삭제금지
자바 Abstract관련 소스코딩중 잘 되지 않아 질문 드립니다.  Mobile.java  ==============================================================================================  public abstract class Mobile {  private String mobileName; private int batterySize; private String osType;  public Mobile() {   }  public Mobile(String mobileName, int batterySize, String osType) { this.mobileName = mobileName; this.batterySize = batterySize; this.osType = osType; }    public String getMobileName() { return mobileName; }  public void setMobileName(String mobileName) { this.mobileName = mobileName; }  public int getBatterySize() { return batterySize; }  public void setBatterySize(int batterySize) { this.batterySize = batterySize; }  public String getOsType() { return osType; }  public void setOsType(String osType) { this.osType = osType; }  public abstract int operate(int time);  public abstract int charge(int time);  }    MobileTest.java  ===========================================================================================  import com.mobile.OTab;  public class MobileTest {  public static void main(String[] args) {  OTab ot = new OTab("OTab", 1000, "AND-20");   System.out.println(" Mobile\t\tBattery\t\tOS"); System.out.println("---------------------------------------------");  System.out.println(ot.getMobileName()+ "\t\t" + ot.getBatterySize() + "\t\t" + ot.getOsType()); System.out.println("---------------------------------------------"); System.out.println(); System.out.println("10분 충전");  ot.charge(10); System.out.println(" Mobile\t\tBattery\t\tOS"); System.out.println("---------------------------------------------");  System.out.println(ot.getMobileName()+ "\t\t" + ot.getBatterySize() + "\t\t" + ot.getOsType()); System.out.println("---------------------------------------------"); System.out.println(); System.out.println("5분 통화");  ot.operate(5); System.out.println(" Mobile\t\tBattery\t\tOS"); System.out.println("---------------------------------------------");  System.out.println(ot.getMobileName()+ "\t\t" + ot.getBatterySize() + "\t\t" + ot.getOsType()); System.out.println("---------------------------------------------"); }  }    OTab.java  =============================================================================================  import com.mobile.Mobile;  class OTab extends Mobile{  public OTab(){ super(); } public OTab(String mobileName, int batterySize, String osType){ super(mobileName, batterySize, osType); setBatterySize(batterySize); setMobileName(mobileName); setOsType(osType);  }  public int operate(int time){ int a = time*12;  return getBatterySize()-a; }  @Override public int charge(int time) { int b = time*10;  return getBatterySize()+b; }   }    위 Mobile.java와 MobileTest.java를 사용하여 OTab.java를 구현하는 건데요..  다음과 같이 구현해봤는데, 값이 모두 Null로 나오네요..    문제가 뭘까요..?  
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호