분류 전체보기122 상속 클래스 package tt; class Tv { boolean power; // 전원(on/off) int channel; // 채널 void power() { power = !power; } // 전원 void channelUp() { ++channel; } // 채널 증가 void channelDown() { --channel; } // 채널 감소 } class CaptionTv extends Tv { boolean caption; // caption 상태(on/off) void displayCaption(String text) { if (caption) { // caption 상태가 on(true)일때 text를 보여준다. System.out.println(text); } } } class CaptionT.. 2024. 1. 22. JAVA MBTI 심리 테스트 코딩 과정 package ex09; import java.util.Scanner; public class Ex07 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("이름을 입력하세요"); String a = sc.nextLine(); System.out.println("이름은 =" + a); System.out.println("성별을 입력하세요"); String b = sc.nextLine(); System.out.println("성별은 =" + b); int sum1 = 0; int sum2 = 0; int sum3 = 0; int sum4 = 0; System.out.println(".. 2024. 1. 19. 메소드 오버로딩 이번 수업의 내용은 메소드 오버로딩 하는법 package ex09; public class AA { //오버로딩 기법 // 매개 변수만 다르면 된다. // public void doA() { System.out.println("기본"); } public void doB(int a,int b) { System.out.println("a = "+ a); System.out.println("b = "+ b); } public void doC(String c) { System.out.println("c = "+ c); } // static 사용 --------------- public static void doD() { System.out.println("기본"); } public static void doE(.. 2024. 1. 19. 홀짝에 따라 다른 값 반환하기 package ex07; import java.util.Scanner; class Park { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int answer =0; if (n % 2 == 0) { for (int i = 2; i 2024. 1. 18. 이전 1 ··· 26 27 28 29 30 31 다음