본문 바로가기

솔루션모음113

[파워자바] 14장 프로그래밍 솔루션 답지 1. // 패키지 포함 import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; // JFrame을 상속받는 MyFrame 클래스 선언 class MyFrame extends JFrame { // 필드선언 private JButton button; private JLabel label; private JTextField textInput,textResult; private JPanel panel,panel1,panel2,panel3; // 생성자 선언 public .. 2023. 2. 15.
[파워자바] 13장 프로그래밍 솔루션 답지 1. mport java.awt.*; import javax.swing.*; class TestFrame extends JFrame{ public TestFrame(){ setSize(500,100); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setTitle("테스트 프레임"); JPanel panel = new JPanel(); JLabel label = new JLabel("자바는 재미있나요?"); JButton button1 = new JButton("Yes"); JButton button2 = new JButton("No"); panel.add(label); panel.add(button1); panel.add(button2); add(panel); s.. 2023. 2. 15.
[파워자바] 12장 프로그래밍 솔루션 답지 1. interface Movable { void move(int dx, int dy); } class Shape implements Movable { protected int x, y; public void draw() { System.out.println("Shape Draw"); } public void move(int dx, int dy) { x = dx; y = dy; } }; class Rectangle extends Shape { private int width, height; public void setWidth(int w) { width = w; } public void setHeight(int h) { height = h; } public void draw() { System.out.p.. 2023. 2. 15.
[파워자바] 11장 프로그래밍 솔루션 답지 1. class Circle { double radius; String color; public Circle(double radius) { super(); this.radius = radius; } public Circle() { super(); this.radius = 0; } public double getRadius() { return radius; } public void setRadius(double radius) { this.radius = radius; } public double getArea() { return 3.141592 * radius * radius; } } class Cylinder extends Circle { public Cylinder(double radius, doubl.. 2023. 2. 15.