코딩
-
비행기 정보(생성자)코딩/java 2019. 2. 8. 02:04
public class Plane { String model; int id, capacity; public static int plane; public String toString() { return "식별번호: " + id + "편\n모델: " + model + "\n승객수: " + capacity +"명\n"; } public void setModel(String model) { this.model = model;} public void setId(int id) {this.id = id;} public void setCapacity(int capacity) {this.capacity = capacity;} public Plane() { this(0, "모름", 0); } public Plane(int..
-
은행계좌(생성자)코딩/java 2019. 2. 8. 01:57
import java.util.Random; public class BankAccount { Random rd = new Random(); private String name, accountNo; private int balance; private double interest; public void setName(String n) { name = n;} public void setAccountNo(String a) {accountNo = a;} public void setBalance(int b) {balance = b;} public void setRate(double r) {interest = r;} public String getName() {return name;} public String get..
-
영화 정보 출력(생성자)코딩/java 2019. 1. 7. 22:23
import java.util.Random; public class Movie { Random rd = new Random(); private String title, director, mid; private int score, year; public void setTitle(String title) {this.title = title;}; public void setDirector(String director) {this.director = director;}; public void setScore(int score) {this.score = score;}; public void setYear(int year) {this.year = year;}; public void setMid(String mid)..
-
랜덤 숫자 200개 출력코딩/java 2019. 1. 7. 00:32
import java.util.Random; public class Practice_52 { public static void main(String[] args) { Random rg = new Random(); int n100 = 0, n999 = 0; for (int i = 0; i < 200; i++) { int num = rg.nextInt(900) + 100; System.out.print(num); if (num == 100) { System.out.print("*"); n100++; } else if(num == 999) { System.out.print("+"); n999++; } System.out.print("\t"); if (i % 10 == 9) { System.out.println..
-
상자의 정보코딩/java 2019. 1. 6. 23:44
public class Box { private int x; private int y; private int z; private boolean empty; public String toString() { String rslt = "가로: " + x + "cm\n세로: " + y + "cm\n높이: " + z + "cm\n"; if (empty) return rslt + "지금 박스는 비어있습니다.\n"; else return rslt + "지금 박스에는 물건이 들어있습니다.\n"; } public void setX(int x) {this.x = x;} public void setY(int y) {this.y = y;} public void setZ(int z) {this.z = z;} public int..
-
비행기 정보(생성자)코딩/java 2019. 1. 6. 23:26
public class Plane { String model; int id, capacity; public String toString() { return "식별번호: " + id + "\n모델: " + model + "\n승객수: " + capacity +"\n"; } public void setModel(String model) { this.model = model;} public void setId(int id) {this.id = id;} public void setCapacity(int capacity) {this.capacity = capacity;} public Plane() { this(0, "모름", 0); } public Plane(int i, String m, int c) { this..
-
생일, 성년일 계산(설정자, 접근자)코딩/java 2019. 1. 6. 23:13
public class Date { private int year; private int month; private int day; public String toString() { String rslt; rslt = year + "년" + month + "월" + day + "일"; return rslt; } public void setYear(int year) { this.year = year;} public void setMonth(int month) { this.month = month;} public void setDate(int day) { this.day = day;} public int getYear() {return year;} public int getMonth() {return mont..
-
은행 계좌(toString, 설정자, 접근자)코딩/java 2019. 1. 6. 21:57
public class BankAccount { private String name, accountNo; private int balance; private double rate; public void setName(String n) { name = n;} public void setAccountNo(String a) {accountNo = a;} public void setBalance(int b) {balance = b;} public void setRate(double r) {rate = r;} public String getName() {return name;} public String getAccountNo() {return accountNo;} public int balance() {retur..