Java(8)
-
Java - 객체(2)
클래스 public class People { int age; String name; int x, y; int speed; public People(String name, int age, int spped, int x, int y){ //이름 나이 속도와 좌표를 입력받는 생성자 this.name = name; this.age = age; this.speed = spped; this.x = x; this.y = y; } public People(String name, int age, int speed){ //이름 나이 속도만 입력해서 생성할경우 기본 좌표 0,0 this(name, age, speed, 0, 0); } public String getLocation(){ //현재 위치 출력하는 메소드 ret..
2022.04.25 -
Java - 객체(1)
1.고객정보를 출력하는 예제 import java.util.*; public class Main { public static class Order{ int orderNum; String customerID; String orderDate; String customerName; public void OrderInfo(){ System.out.println("주문번호 : "+ orderNum); System.out.println("주문날짜 : "+ orderDate); System.out.println("고객아이디 : "+ customerID); System.out.println("고객명 : "+ customerName); } } public static void main(String[] args) { Or..
2022.04.21