본문 바로가기

자바과정/Java35

Java 실습(상속클래스) - 6일차 // AA 클래스 package Test; public class AA { private int a; public AA (int a){ // 서브 클래스로부터 값을 받음 // super(); // Object 클래스 호출 기본값임 this.a = a; // 첫번째 인자값 사용 } public int getA() { return a; } } // BB 클래스 package Test; public class BB extends AA{ private int b; public BB(int a, int b) { // 생성자 호출완료, 인자값 받음 super(a); // AA 클래스(상위 클래스) 인자값과 동시에 호출 this.b = b; // 2번째 인자값인 b를 사용 } public int getB() { re.. 2021. 2. 4.
Java 실습(한사람 성적처리:과목수 입력) - 5일차 // 이름 클래스 package Day5; // 이름입력 데이터 클래스 public class NameStudent { private String name; // setter public void setName(String name) { this.name = name; } // getter public String getName() { return name; } } // 과목 입력 클래스 package Day5; // 과목 입력 데이터 클래스 public class Subject { private int []score; // 입력받을 과목 필드 선언 private float avg; private int tot; // private int tot; // private float avg; // 과목은 사용.. 2021. 2. 4.
Java 실습(성적처리프로그램:클래스) - 5일차 --- StudentScore 클래스 /* * 성적처리프로그램 * 입력 : 이름, 국, 영, 수 * 연산 : 총점, 평균 * 출력 : 이름, 국, 영, 수, 총, 평 */ //import java.util.Scanner; public class StudentScore { private String name; private int []score; //= new int[4];//국 영 수 총 private float avg; public StudentScore() { name = ""; score = new int[4]; avg = 1.f; } public void setName(String name) { this.name = name; } public void setScore(int i, int score.. 2021. 2. 3.
Java 기초 - 5일차 --------------------------this 보완 -- 내 코드 ------ this에 대한 실습코드 public class ThisCall { //field private int i,j; //constructor //오버로딩 public ThisCall() { } public ThisCall(int i) { this.i = i; } public ThisCall(int i, int j) { this.i = i; this.j = j; } //method public int getA() { return i; } public int getB() { return j; } public static void main(String[] args) { ThisCall tc1 = new ThisCall(); T.. 2021. 2. 3.