// 클래스 이름
public class Person {
//멤버변수(필드)
//상태, 속성
int x, y;
int power;
String color;
String name;
//멤버메소드
//동작, 기능 수행
void moveForward() {
x+=5;
}
void moveBack() {
y-=5;
}
// 생성자
//멤버변수초기화(this는 객체 자신 의미)
//객체멤버와 구별 시키기 위해서
Person(int x, int y, String color, String name) {
this.x=x;
this.y=y;
this.color=color;
this.name=name;
}
}
//객체생성
1.
클래스명 객체명 = new 클래스명();
Person r1 = new Person(); // (사람이 생성 됨)
2. (이건 뭐지?)
Person Person1; // 객체 선언 객체 이름
r1 = new Person(); //객체 생성
3.
r1.color = "Red"; //객체명.멤버변수
r.1.name = "Person1";
2-2.
Person r2 = new Person();
r2.color = "노란색";
r2.name = "Person2";
안드로이드 앱 화면 구성 공부 조금 함..
<Button
andoid:layout_width="wrap_content"
andoid:layout_height="wrap_content"
andoid:text="BUTTON~!" />
wrap_content : 뷰 크기에 맞추어 크기를 지정.