원 a : Circle(2,3)반지름5 원 b : Circle(2,3)반지름30 같은 원 *두 객체의 중심이 같으면 같은 것으로 판별* public class Circle { private int x,y,radius; public Circle(int x, int y, int radius) { // TODO Auto-generated constructor stub this.x = x; this.y = y; this.radius = radius; } public String toString() { return "Circle("+x+","+y+")반지름"+radius; } public boolean equals(Object obj) { Circle c = (Circle)obj; if(x==c.x && y==c..
전체 글
public class MyPoint { private int x,y; public MyPoint(int x, int y) { // TODO Auto-generated constructor stub this.x = x; this.y = y; } public String toString() { return "Point("+x+","+y+")"; } public static void main(String[] args) { // TODO Auto-generated method stub MyPoint p = new MyPoint(3,50); MyPoint q = new MyPoint(4,50); System.out.println(p); if(p.equals(q)) { System.out.println("같은 점..
import java.util.Scanner; public class open { int alphabet[] = new int[26]; String readString() { System.out.println("영문 텍스트를 입력하고 세미콜론을 입력하세요."); StringBuffer sb = new StringBuffer();//키 입력을 받을 스트링 버퍼 생성 Scanner scanner = new Scanner(System.in); while(true) { String line = scanner.nextLine(); if(line.length() == 1 &&line.charAt(0)==';') {//';'만 있는 라인이면 break; } sb.append(line);//읽은 라인 문자열을 스트링 ..
public interface Shape { final double PI = 3.14; void draw(); double getArea(); default public void redraw() { System.out.print("--- 다시 그립니다. "); draw(); } } public class Circle implements Shape { private int radius; public Circle(int radius) { // TODO Auto-generated constructor stub this.radius = radius; } @Override public void draw() { // TODO Auto-generated method stub System.out.println("반지름..
public interface Shape { final double PI = 3.14; void draw(); double getArea(); default public void redraw() { System.out.print("--- 다시 그립니다. "); draw(); } } public class Circle implements Shape { private int radius; public Circle(int radius) { // TODO Auto-generated constructor stub this.radius = radius; } @Override public void draw() { // TODO Auto-generated method stub System.out.println("반지름..
public abstract class Shape { private Shape next; public Shape() {next = null;} public void setNext(Shape obj) {next = obj;} public Shape getNext() {return next;} public abstract void draw(); } import java.util.Scanner; class Line extends Shape{ @Override public void draw() { // TODO Auto-generated method stub System.out.println("Line"); } } class Rect extends Shape{ @Override public void draw()..