문제 아래의 2개 클래스와 1개의 인터페이스를 작성하고, 실행결과를 출력하시오! (익명 구현 객체) Vehicle (인터페이스) Anonymous, AnonymousExample Vehicle(인터페이스) 멤버함수 public void run() *추상메서드 public void speedup() *추상메서드 Anonymous(클래스) 멤버변수 int Speed * 생성자이용 -1로 초기화 Vehicle field *익명 구현 클래스 구현 (추상 메서드 재 정의) void passengerCar() * 로컬 변수의 익명 구현 클래스 구현 (추상 메서드 재 정의) void airPlane(Vehicle v) * 매개 변수의 익명 구현 클래스 구현 (추상 메서드 재 정의) AnonymousExample(실행..
Java
interface Cha { void skill(); } class A { void Attack(Cha b) { b.skill(); System.out.println("공격"); } } class B implements Cha { public void skill() { System.out.println("마법사"); } } class C implements Cha { public void skill() { System.out.println("전사"); } } class D implements Cha { public void skill() { System.out.println("전사"); } } // //class C{ //void skill() { //System.out.println("전사"); //}..
문제 아래의 2개 클래스와 1개의 인터페이스를 작성하고, 실행결과를 출력하시오! Stack (인터페이스) StringStack, StringStackExample Stack(인터페이스) 멤버함수 int length(void) *추상메서드 Object pop(void) *추상메서드 void push(Object s) *추상메서드 StringStack Class(조상클래스) 멤버변수 private String[] s private int n 멤버함수 public int length(void) *알아서 구현 public Object pop(void) *알아서 구현 public void push(Object s) *알아서 구현 StringStackExample(실행클래스) 결과 스택크기 입력: 5 5개의 스택영..
문제 아래의 3개의 클래스와 2개의 인터페이스를 작성하고, 실행결과를 출력하시오! MobilePhone, MP3 (인터페이스) PDA, SmartPhone, SmartPhoneExample MobilePhone(인터페이스) 멤버함수 void sendCall(void) void receiveCall(void) void sendSMS(void) void receiveSMS(void) MP3(인터페이스) 멤버함수 void play(void) void stop(void) PDA Class(조상클래스) 멤버함수 int calcuate(int a, int b) *출력결과보고 구현 SmartPhone Class(자식클래스)->인터페이스 구현(2개) 멤버함수 void sendCall(void) 출력결과 보고 재 정의 ..
문제 아래의 3개의 클래스와 1개의 인터페이스를 작성하고, 실행결과를 출력하시오! RemoteControl(인터페이스) Television, Audio, RemoteControlExample RemoteControl(인터페이스) 멤버변수 int MAX_VOLUME *10으로 초기화 int MIN_VOLUME *0으로 초기화 멤버함수 void turnOn(void) *추상메서드 void turnOff(void) *추상메서드 void setVolume(int volume) *추상메서드 default void setMute(boolean mute) *디폴트메서드 출력결과 보고 구현 static void changeBattery(void) *정적메서드 출력결과 보고 구현 Television Class(구현클래스..
문제 아래의 4개 클래스와 1개의 인터페이스를 작성하고, 실행결과를 출력하시오! Vehicle (인터페이스) Bus, Taxi, Driver, DriverExample Vehicle(인터페이스) 멤버함수 void run(void) *추상메서드 void stop(void) *추상메서드 Bus Class(구현클래스) 멤버함수 void run(void) void stop(void) Taxi Class(구현클래스) 멤버함수 void run(void) void stop(void) Driver(독립클래스) 멤버함수 void drive(Vehicle) void stop(Vehicle) DriverExample(실행클래스) 결과 버스가 달립니다. 버스가 멈춥니다. 택시가 달립니다. 택시가 멈춥니다. 코드 interfa..
문제 아래의 5개의 클래스를 작성하고, 메인에서 아래와 같은 실행 결과를 출력하시오(추상 클래스) Ship, Boat, Cruise, ShipUtill, ShipExample Ship Class(조상 / 추상클래스) 멤버변수 int person int weapon 멤버함수 생성자구현 public abstract int move(void) *인원 public abstract int carry(void) *무기 Boat Class(자손클래스) 멤버변수 String name 멤버함수 public int move(void) *인원 public int carry(void) *무기 public String name(void) Cruise Class(자손 클래스) 멤버변수 String name 멤버함수 public ..
문제 아래의 6개의 클래스를 작성하고, 메인에서 아래와 같은 실행결과를 출력하시오(추상 클래스) Calc, Add, Sub, Mul, Div, Calculator Calc Class(조상 / 추상 클래스) 멤버변수 double a double b 멤버함수 void setValue(double, double) abstract double calculate(void) *추상메서드 Add Class(자식클래스) 멤버함수 abstract double calculate(void) *오버라이딩 Sub Class(자식클래스) 멤버함수 abstract double calculate(void) *오버라이딩 Mul Class(자식클래스) 멤버함수 abstract double calculate(void) *오버라이딩 DIv..