public abstract class Calc { protected int a; protected int b; void setValue(int a,int b) { this.a = a; this.b = b; } abstract int calculate(); } import java.util.Scanner; class Add extends Calc{ @Override int calculate() { return a+b; } } class Sub extends Calc{ @Override int calculate() { // TODO Auto-generated method stub return a-b; } } class Mul extends Calc{ @Override int calculate() { // ..
전체 글
abstract class PairMap{ protected String keyArray [];//key들을 저장하는 배열 protected String valueArray [];//value들을 저장하는 배열 abstract String get(String key);//key값을 가진 value 리턴, 없으면 null abstract void put(String key, String value);//key와 value를 쌍으로 저장, 기존에 키가 있으면, 값을 수정 abstract String delete(String key);//key값을 가진 아이템(value와 함께) 삭제, t삭제된 value값을 리턴 abstract int length();//현재 저장된 아이템의 개수 리턴 } class Dic..
import java.util.Scanner; interface Stack{ int length(); int capacity(); String pop(); boolean push(String val); } class StringStack implements Stack{ private String[] element; //스택의 저장 메모리 private int tos;//index,top of stack public StringStack(int capacity) { // TODO Auto-generated constructor stub element = new String[capacity]; tos = -1; } @Override public int length() { // TODO Auto-generat..
class Point { private int x,y; public Point(int x,int y) {this.x = x; this.y = y;} public int getX() {return x;} public int getY() {return y;} protected void move(int x,int y) {this.x= x; this.y = y;} } public class PositivePoint extends Point { public PositivePoint() { // TODO Auto-generated constructor stub super(0,0); } public PositivePoint(int x, int y) { super(x,y); if(getX()>=0&&getY()>=0)..
class Point { private int x,y; public Point(int x,int y) {this.x = x; this.y = y;} public int getX() {return x;} public int getY() {return y;} protected void move(int x,int y) {this.x= x; this.y = y;} } public class Point3D extends Point { private int z; public Point3D(int i, int j, int z) { // TODO Auto-generated constructor stub super(i,j); this.z = z; } public void move(int i, int j, int z) {..
class Point { private int x,y; public Point(int x,int y) {this.x = x; this.y = y;} public int getX() {return x;} public int getY() {return y;} protected void move(int x,int y) {this.x= x; this.y = y;} } public class ColorPoint extends Point { private String color; public ColorPoint(int x, int y,String color) { super(x, y); this.color = color; } public ColorPoint() { super(0,0); color = "BLACK"; ..