목록JAVA/chapter15_access_modifer (7)
WON.dev
package org.joonzis.ex; public class Ex07_Triangle { // Field private int width; private int height; // Constructor public Ex07_Triangle(){ this(1, 1); } public Ex07_Triangle(int width, int height){ this.width = width; this.height = height; } // Method private double calcArea() { return width * height / 2.0; } public void output() { System.out.println("너비 : " + width); System.out.println("높이 : "..
package org.joonzis.ex; public class Ex06_Local { private String name; private int age; private String sn; private boolean isKorean; public Ex06_Local(String name, int age) { this(name, age, null); } public Ex06_Local(String name, int age, String sn){ this.name = name; this.age = age; this.sn = sn; if(sn != null) { this.isKorean = sn.charAt(7)
package org.joonzis.ex; public class Ex05_Circle { // Field private int x; private int y; private double radius; // Constructor public Ex05_Circle() { this(0, 0, 1); } public Ex05_Circle(double radius){ this(0, 0, radius); } public Ex05_Circle(int x, int y, double radius){ this.x = x; this.y = y; this.radius = radius; } // Method (Main에서 output만 호출하기 때문에, output에 calcArea,calcCircum이 들어가있으므로,out..
package org.joonzis.ex; public class Ex04_Book { // Field private String title; private String writer; private int price; private int salesVolume;// 판매량 private boolean isBestSeller;// 판매량이 1000 이상이면 true, 아니면 false // Constructor public Ex04_Book(){ } public Ex04_Book(String title, String writer, int price){ this.title = title; this.writer = writer; this.price = price; } public Ex04_Book(String..
package org.joonzis.ex; public class Ex03_Person { private String name; private int age; private double height; private char gender; public Ex03_Person() {} public Ex03_Person(String name, int age, double height, char gender) { this.name = name; this.age = age; this.height = height; this.gender = gender; } public String getName() { return name; } public void setName(String name) { // 이름의 길이가 반드시..
package org.joonzis.ex; import java.util.Scanner; /* * 필드 * - String name, dept, score1, score2 * - double average * - boolean isPass * * 메소드 * - 생성자(name, dept) * - input(scanner) : 중간, 기말, 평균, 패스 유무 초기화 * - getAverage() : 평균 값 리턴 * - isPass() : 패스유무 리턴 (평균 80 이상 통과) * - output() : 이름 , 학과, 평균, 합격or불합격 출력 */ public class Ex02_Student { private String name, dept, score1, score2; private double a..
package org.joonzis.ex; /* * 필드 * - width, height, isSquare * * 메소드 * - 생성자() : 가로, 세로 1로 고정 * - 생성자(int side) : 가로, 세로 같은 값으로 저장 * - 생성자(w, h): 가로, 세로 값 전달 받아 저장 * - int calcArea() : 사각형 크기 리턴 * - output() : 너비, 높이, 크기, 형태 (정사각형or 직사각형) 출력 * */ public class Ex01_Rect { private int width, height; private boolean isSquare; public Ex01_Rect() { this(1, 1); } public Ex01_Rect(int side) { this(side,..