1.
public class Dog {
private String name;
private String breed;
private int age;
public Dog(String name, int age){
this.name = name;
this.age = age;
}
public Dog(String name, String breed, int age){
this.name = name;
this.breed = breed;
this.age = age;
}
public String getName()
{
return name;
}
public String getBreed()
{
return breed;
}
public int getAge()
{
return age;
}
public void setName(String n)
{
name = n;
}
public void setBreed(String b)
{
breed = b;
}
public void setAge(int a)
{
age = a;
}
}
2.
class Plane{
private int num, p_num;
private String model;
private static int planes;
public void setNum(int n){
num = n;
}
public void setPnum(int pn){
p_num = pn;
}
public void setModel(String m){
model = m;
}
public int getNum(){
return num;
}
public int getPnum(){
return p_num;
}
public String getModel(){
return model;
}
public static void setPlanes(int p){
planes = p;
}
public static int getPlanes(){
return planes;
}
public Plane(){ }
public Plane(int n, String m, int pn){
num = n;
p_num = pn;
model = m;
}
public Plane(int n, String m){
num = n;
model = m;
}
public String toString(){
return "식별번호 :" + getNum() + "모델 : " + getModel() + "승객수 : " + getPnum();
}
}
public class PlaneTest {
public static void main(String[] args){
Plane plane1 = new Plane(1, "aa", 200);
Plane plane2 = new Plane(2, "bb");
Plane plane3 = new Plane();
plane1.setPlanes(0);
plane1.getPlanes();
plane3.setNum(3);
plane3.setModel("cc");
plane3.setPnum(150);
}
}
3.
public class Box {
private int width, length, height;
private boolean empty = false;
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getLength() {
return length;
}
public void setLength(int length) {
this.length = length;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public boolean isEmpty() {
return empty;
}
public void setEmpty(boolean empty) {
this.empty = empty;
}
public Box()
{
width = 0;
length = 0;
height = 0;
empty = true;
}
public Box(int w, int l, int h){
width = w;
length = l;
height = h;
empty = true;
}
}
4.
public class Movie {
private String title;
private String direction;
private String company;
public Movie(){}
public Movie(String t, String d, String c){
title = t;
direction = d;
company = c;
}
}
5.
public class BankAccount {
private String ownerName;
private int accountNumber;
private int balance;
private double rate;
public String getOwnerName() {
return ownerName;
}
public void setOwnerName(String ownerName) {
this.ownerName = ownerName;
}
public int getAccountNumber() {
return accountNumber;
}
public void setAccountNumber(int accountNumber) {
this.accountNumber = accountNumber;
}
public int getBalance() {
return balance;
}
public void setBalance(int balance) {
this.balance = balance;
}
public double getRate() {
return rate;
}
public void setRate(double rate) {
this.rate = rate;
}
public BankAccount()
{
}
public BankAccount(String n, int a, int b, double r){
ownerName = n;
accountNumber = a;
balance = b;
rate = r;
}
}
'솔루션모음 > 파워자바 프로그래밍' 카테고리의 다른 글
[파워자바] 11장 프로그래밍 솔루션 답지 (0) | 2023.02.15 |
---|---|
[파워자바] 10장 프로그래밍 솔루션 답지 (0) | 2023.02.15 |
[파워자바] 8장 프로그래밍 솔루션 답지 (0) | 2023.02.15 |
[파워자바] 7장 프로그래밍 솔루션 답지 (0) | 2023.02.15 |
[파워자바] 6장 프로그래밍 솔루션 답지 (0) | 2023.02.15 |
댓글