Compare commits
No commits in common. "504ce3feaf68dbe6578653ae2d75d0ab1a9fea24" and "55abafec703fc243837fb91036b02eeeb08bf100" have entirely different histories.
504ce3feaf
...
55abafec70
|
|
@ -1,5 +1,2 @@
|
||||||
/mana/
|
/ppl/
|
||||||
/User/
|
|
||||||
/a/
|
|
||||||
/ver/
|
/ver/
|
||||||
/java/
|
|
||||||
|
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
package User;
|
|
||||||
|
|
||||||
import java.util.Scanner;
|
|
||||||
|
|
||||||
public class management {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
user[] users= new user[10];
|
|
||||||
int index=0;
|
|
||||||
Scanner s=new Scanner(System.in);
|
|
||||||
|
|
||||||
while(true){
|
|
||||||
System.out.println("1.사용자추가 2.사용자정보3.사용자삭제4.종료");
|
|
||||||
System.out.println("몇번?:");
|
|
||||||
int a=s.nextInt();
|
|
||||||
System.out.println("입력한 정수 : " + a);
|
|
||||||
int choice =s.nextInt();
|
|
||||||
if(choice == 1) {
|
|
||||||
user u= new user();
|
|
||||||
u.name= s.next();
|
|
||||||
u.age=s.nextInt();
|
|
||||||
|
|
||||||
users[index]=u;
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
if(choice==4) {
|
|
||||||
s.close();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
// 무한반복
|
|
||||||
// 메뉴 1. 사용자 정보
|
|
||||||
// 2. 사용자 추가
|
|
||||||
// 3. 사용자 삭제
|
|
||||||
// 4. 사용자 정보
|
|
||||||
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
package User;
|
|
||||||
|
|
||||||
public class user {
|
|
||||||
|
|
||||||
String name;
|
|
||||||
int age;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
package a;
|
|
||||||
|
|
||||||
import ver.Rectangle;
|
|
||||||
|
|
||||||
public class Circle extends Triangle{
|
|
||||||
protected int radius;
|
|
||||||
|
|
||||||
public void draw(){
|
|
||||||
System.out.println("반지름 " + radius);
|
|
||||||
Rectangle r = new Rectangle();
|
|
||||||
int cHeight = r.height; // 정상
|
|
||||||
Triangle t = new Triangle(); // 정상
|
|
||||||
// cHeight = t.height; // 오류
|
|
||||||
// cHeight = height; // 오류
|
|
||||||
int cWidth = t.width; // 정상
|
|
||||||
cWidth = width; // 정상
|
|
||||||
int width = t.width; // 정상
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
package a;
|
|
||||||
|
|
||||||
import ver.Rectangle;
|
|
||||||
|
|
||||||
class Triangle {
|
|
||||||
protected int width;
|
|
||||||
private int height;
|
|
||||||
|
|
||||||
public void draw(){
|
|
||||||
System.out.println("가로 " + width + ", 세로 " + height);
|
|
||||||
Rectangle r = new Rectangle();
|
|
||||||
int height = r.height; // 정상
|
|
||||||
System.out.println("높이 " + height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
package java;
|
|
||||||
|
|
||||||
|
|
||||||
public class Circle extends Shape implements Drawing {
|
|
||||||
|
|
||||||
protected int r;
|
|
||||||
|
|
||||||
public Circle() {
|
|
||||||
r = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Circle(int r) {
|
|
||||||
this.r = r;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double area() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return Math.PI * r * r;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int draw() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
System.out.println(title + " : 원을 그립니다.");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
package java;
|
|
||||||
|
|
||||||
//public interface Drawing {
|
|
||||||
interface Drawing {
|
|
||||||
public String title = "그리는 인터페이스 입니다.";
|
|
||||||
public int draw();
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
package java;
|
|
||||||
|
|
||||||
//public class Line {
|
|
||||||
public class Line extends Shape {
|
|
||||||
|
|
||||||
protected int startX;
|
|
||||||
|
|
||||||
public Line() {
|
|
||||||
startX = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Line(int startX) {
|
|
||||||
this.startX = startX;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double area() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return startX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int draw() {
|
|
||||||
// System.out.println(title + " : 원을 그립니다."); // 오류, 인터페이스를 선언하지 않았다.
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
package java;
|
|
||||||
|
|
||||||
public class Rectangle extends Shape implements Drawing {
|
|
||||||
|
|
||||||
protected int x, y;
|
|
||||||
|
|
||||||
public Rectangle() {
|
|
||||||
x = 0;
|
|
||||||
y = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Rectangle(int x, int y) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double area() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return x * y;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int draw() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
System.out.println(title + " : 사각형을 그립니다.");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
|
|
||||||
public class Scatchbook {
|
|
||||||
private String name;
|
|
||||||
private Drawing[] drawList; // 배열은 크기를 동적으로 조절하기가 힘들다. Chap23, 24 제네릭과 컬렉션을 통해 동적으로 크기를 조정하는 것을 배우게 된다.
|
|
||||||
|
|
||||||
public Scatchbook(String name, int size) {
|
|
||||||
this.name = name;
|
|
||||||
this.drawList = new Drawing[size];
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addDrawing(Drawing d){
|
|
||||||
for(int index = 0; index < drawList.length; index++){
|
|
||||||
if(drawList[index] == null) {
|
|
||||||
drawList[index] = d;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
public void draw(){
|
|
||||||
for(Drawing d : drawList) System.out.println(d.draw());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String args[]) {
|
|
||||||
Scatchbook scatchbook = new Scatchbook("SWH아카데미 스케치북", 2);
|
|
||||||
Circle circle = new Circle(5000);
|
|
||||||
Line line = new Line(5);
|
|
||||||
Rectangle rectangle = new Rectangle();
|
|
||||||
|
|
||||||
scatchbook.addDrawing(circle);
|
|
||||||
scatchbook.addDrawing(rectangle);
|
|
||||||
// scatchbook.addDrawing(line); // 컴파일 오류
|
|
||||||
scatchbook.draw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
package java;
|
|
||||||
|
|
||||||
public abstract class Shape {
|
|
||||||
protected int x, y;
|
|
||||||
|
|
||||||
public abstract double area();
|
|
||||||
public void move(int x1, int y1) {
|
|
||||||
x += x1;
|
|
||||||
y += y1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
package mana;
|
|
||||||
|
|
||||||
public class User {
|
|
||||||
|
|
||||||
String name;
|
|
||||||
int age;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
package mana;
|
|
||||||
|
|
||||||
public class UserManagement {
|
|
||||||
|
|
||||||
private User[] list;
|
|
||||||
|
|
||||||
public void init(){
|
|
||||||
list = new User[10];
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(User u){
|
|
||||||
list[0] = u;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void insert(int index, User u){
|
|
||||||
list[index] = u;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(String name, int age, String id){
|
|
||||||
User u = new User();
|
|
||||||
((Object) u).setAge(age);
|
|
||||||
list[0] = u;
|
|
||||||
}
|
|
||||||
|
|
||||||
public User modify(int index, User u){
|
|
||||||
list[index] = u;
|
|
||||||
return list[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
public void view(){
|
|
||||||
User u = list[0];
|
|
||||||
System.out.println("이름: " + u.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
// 무한반복
|
|
||||||
// 메뉴 1. 사용자 정보
|
|
||||||
// 1.1. 사용자 추가
|
|
||||||
// 1.2. 사용자 삭제
|
|
||||||
// 1.3. 사용자 정보
|
|
||||||
|
|
||||||
UserManagement mnt = new UserManagement();
|
|
||||||
mnt.init();
|
|
||||||
mnt.add("코야", 8, "123");
|
|
||||||
|
|
||||||
User k = new User ();
|
|
||||||
mnt.modify(0, k);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
package mana;
|
|
||||||
|
|
||||||
|
|
||||||
public class mana {
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
private int age;
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
public mana(String name, String id){
|
|
||||||
this.id = id;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
public int getAge() {
|
|
||||||
return age;
|
|
||||||
}
|
|
||||||
public void setAge(int age) {
|
|
||||||
this.age = age;
|
|
||||||
}
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
package mana;
|
|
||||||
|
|
||||||
public class managemunt {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
package ver;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue