검색결과 리스트
글
130513
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package point4dtest;
/**
*
* @author User
*/
class Circle {
final double pi;
double area_result;
int x, y, r;
/*Circle() {
this(0, 0, 0);
}*/
Circle(int x, int y, int r,double pi) {
//this 하면 위의 r을 사용 (맴버변수)
this.r = r;
this.x = x;
this.y = y;
this.pi=3.14;//this.pi=pi로 하면 인자로 쓰게되고, 3.14로 잡아주면 인자 뭐로오던 간에 3.14로 박힘
}
double area()
{
r=3;
area_result=r*r*pi;
return area_result;
}
//생성자에서 초기화 하는 방법
}
class CircleC {
Point center = new Point();
int r;
CircleC()
{
this(0,0,0);
}
CircleC(int x,int y, int z)
{
center.x=x;
center.y=y;
this.r=r;
}
}
class CircleI extends Point {
int r;
CircleI() {
this(0, 0, 0);
}
CircleI(int x, int y, int r) {
this.r = r;
this.x = x;
this.y = y;
}
}
class Point {
int x, y;
Point(int x, int y) {
this.x = x;
this.y = y;
}
Point() {
this(0, 0);
}
/*
String getLocation() {
return "x :" + x + ", y :" + y;
}
*/
}
class Point3D extends Point {
int z;
Point3D(int x, int y, int z) {
super(x,y);
//this.x = x;
//this.y = y;
this.z = z;
}
Point3D() {
this(0, 0, 0);
}
String getLocation()
{
return "x :" + x + ", y :"+ y+"z :"+z;
}
}
class Point4D extends Point3D {
int t;
Point4D(int x, int y, int z, int t) {
super(x,y,z);
/*this.x = x;
this.y = y;
this.z = z;
*/
this.t = t;
}
Point4D() {
this(0, 0, 0, 0);
}
String getLocation() {
return super.getLocation() + " t : " + t;
}
}
public class Point4DTest {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Point p = new Point(0, 0);
Point p2 = new Point();
Point3D p3 = new Point3D(1, 2, 3);
Point4D p4 = new Point4D(1, 2, 3, 4);
CircleC c2 = new CircleC();
Circle cc = new Circle(1,2,3,4);
Point4D p4d = new Point4D();
System.out.println("p.x : " + p.x + " p.y :" + p.y + " p2.x : " + p2.x + " p2.y : " + p2.y + " p3.z : " + p3.z + " p4.x : " + p4.x + " p4.y : " + p4.y + " p4.z : " + p4.z + " p4.t : " + p4.t + " c2.center.x : "
+c2.center.x);
System.out.println(p4d.getLocation());
System.out.println("circle area : "+cc.area());
}
}
'학교 실습 > HCI' 카테고리의 다른 글
20130522 HCI 과제 완료 (0) | 2013.05.22 |
---|---|
20130522 HCI (0) | 2013.05.22 |
20130508 (0) | 2013.05.08 |
20130507 (0) | 2013.05.07 |
HCI 20130501 (0) | 2013.05.01 |