Java

패키지 클래스는 데이터와 메서드를 묶어 캡슐화한 것이다. 패키지는 클랫스를 묶어서 캡슐화한 것이다. 오늘의 운세 프로그램 오늘의 날짜와 대길, 길, 중길, 소길, 흉 중 하나의 운세를 표시하자. import java.util.GregorianCalendar; import java.util.Random; public class LuckyDraw { public static void main(String[] args) { GregorianCalendar today = new GregorianCalendar(); int y = today.get(GregorianCalendar.YEAR); //연 int m = today.get(GregorianCalendar.MONTH) + 1; //월 int d = toda..
회원가입 클래스 GetMembers를 생성하라 단, 회원 고유의 식별번호(int idNumber)를 부여하고, 생성된 식별 번호의 1의 자리 숫자가 오늘 날짜의 1의자리 숫자와 일치하면 "당첨입니다"라는 문구를 출력한다. 회원가입시 기입하는 정보(field)는 String: id, password, phoneNumber 이다. idNumber은 정적 필드로 정의한다. import java.util.Calendar; import java.util.GregorianCalendar; class GetMembers { private static int idNumber = 0; private static int day; private String id = new String(); private String pas..
일련번호를 부여하는 Id 클래스 생성 class Id를 생성. Id 인스턴스를 생성할 때마다 int형 변수 number이 증가. String형 변수: nickname, password, phoneNumber nickname과 phoneNumber, idNumber값을 가져오는 게터getter 메서드 생성. 단, number 필드와 그것의 게터getter는 static으로 설정할 것. class Id { private static int idNumber=0; private String nickname = new String(); private String password = new String(); private int phoneNumber; // --생성자 --// public Id(String nick..
X좌표와 Y좌표로 이루어진 2차원 좌표 Coordinate 클래스를 작성하자. class Coordinate{ private double x; private double y; // -- 생성자 -- // Coordinate (double x, double y){this.x = x; this.y = y;} // - 메서드 -- // double getX() {return this.x;} double getY() {return this.y;} void setX(double x) { this.x = x;} void setY(double y) { this.y = y;} void setXY(double x, double y) { this.x = x; this.y = y;} } //Coordinate 접근자(acc..
Codezoy
'Java' 태그의 글 목록 (4 Page)