전체 글 (19) 썸네일형 리스트형 5/17 그린 컴퓨터 아카데미 import javax.swing.JFrame; public class Main { public static void main(String[] args) { // GUI // awt swing(우리가 배울곳), javaFx(자바언어를 안치고 다른 문법으로 작성근데 안씀) // GUI 라는 형태를 구현하는 패턴이 아키텍쳐 라고함 // GUI 를 구현하는 구조가 모두 똑같음. (안드로이드 뭐 os 에 따라 달리지지않음 그래서 구식을 배워도 쓰이는곳은 같음.) JFrame frame = new JFrame("처음 GUI 창"); // 인스턴스화 frame.setSize(500, 500); // 가로 세로 사이즈 지정 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE).. 0516 그린 컴퓨터 아카데미 /* 도형 도형은 넓이를 구할 수 있다.= 0 && userWant 그린 컴퓨터 아카데미 5/4 import java.util.Arrays; public class Main4 { public static int[] create(int num, int length) { int[] arr = new int[length]; for (int i = 0; i < arr.length; i++) { arr[i] = num * (i + 1); } return arr; } public static void main(String[] args) { // 4행 5열의 2차원 배열 // 각 행의 원소들은 2~5 // 2 4 6 8 10 // 3 6 9 12 15 // .... // ....20 25 int[][] arr2d = new int[4][5]; for (int i = 0; i < arr2d.length; i++).. 그린 컴퓨터 아카데미 5.2 import java.util.Scanner; public class ArrayTest1 { private static char[] nowSeat = new char[10]; private static int[] userSeat = new int[10]; private static int select; // 현재 예약된 좌석 랜덤으로 뽑기 public static int randomSeat() { int i = (int) (Math.random() * 9) + 1; return i; } // 랜덤으로 예약된 좌석 배열에 설정하기. public static void setSeat() { char[] setSeat = { 'o','o','o','o','o','o','o','o','o','o'}; for (i.. 그린 컴퓨터 아카데미 5/1 import java.time.LocalDate; public class TestDate { public static void main(String[] args) { LocalDate birth = LocalDate.of(1999, 1, 1); LocalDate now = LocalDate.now(); int krAge =now.getYear() - birth.getYear(); int age = 0; if(now.getDayOfYear()>birth.getDayOfYear()) { System.out.println(krAge); }else { System.out.println(krAge-1); } age = now.getYear()-birth.getYear()+1; System.out.println(a.. 그린 컴퓨터 아카데미 4.28 package computer; public class Mouse { String modelName; public String company; public String productionDate; public int price; public Mouse(String modelName, String company, String productionDate, int price) { super(); this.modelName = modelName; this.company = company; this.productionDate = productionDate; this.price = price; } public String getModelName() { return modelName; } public void set.. 그린 컴퓨터 아카데미 4.27 /* 은행 계좌 잔고(정수형) 생성자(모든 필드값 전달받아 초기화 기본생성자(모든필드 기본값 초기화) 입금(입금액) 출금(출금액) 현재잔고 확인 */ public class BankAccount { int balance; public BankAccount(int balance) { this.balance = balance; } public int getBalance() { return balance; } public void setBalance(int balance) { this.balance = balance; } public void deposit(int d) { if (d >= 0) { balance += d; System.out.printf("현재 잔고 %d\n", balance); } } pub.. 그린 컴퓨터 아카데미 4.26 /* 도서 책제목 작가명 가격 문학/비문학 구분 생성자(모든 필드값을 전달받아 초기화) 각 필드의 접근/설정(getter/setter) */ public class BookTest { public static void main(String[] args) { Book life= new Book("모든 삶은 흐른다", "로랑스 드빌레르", 13620,"비문학"); //life.setBookNmae(b); System.out.println("책 제목 :"+ life.getBookName()); //life.setwriter(w); System.out.println("작가 이름: "+ life.getWriter()); //life.setPrice(p); System.out.println("가격 : "+life... 이전 1 2 3 다음