2010년/7월

7월1일 자바(상속 extends,super)

뽀얀햄스터 2010. 7. 1. 12:01

자바는 솔직히 혼자서 프로그램을 짜는것 보다 일반적으로 팀으로 짜는경우가 많고 기본적으로 제공해주는 문서가 일반화 되어있다그래서 쓸때마다 항상 홈페이지에들어가서 클래스를 보고 짜는것이다 그많은것을 기억하기엔 너무 분량이 많다.



일반적인 외부라이브러리같은경우 따로 추가해서 사용하려고하면..  지정해야할것이 있다.




기본적으로 생성과 show start 같다.

package net.itisn;
import com.jme.app.SimpleGame;
import com.jme.scene.shape.Box; //박스사용  
import com.jme.math.Vector3f;  //Test 목표

public class HelloJme extends SimpleGame {
  public static void main(String[] args) {
    HelloJme hj = new HelloJme(); //heap에 객체 생성 
    hj.setConfigShowMode(ConfigShowMode.AlwaysShow);
    hj.start();

  }

  @Override
  protected void simpleInitGame() {
    // TODO Auto-generated method stub
    Box box1 = new Box("My First Game",new Vector3f(0,0,0),new Vector3f(10,10,10));
    rootNode.attachChild(box1);
  }

}


=====================================================================
=====================================================================
package net.itisn;
import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingBox;
import com.jme.bounding.BoundingSphere;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.Node;
import com.jme.scene.Spatial;
import com.jme.scene.shape.Box;
import com.jme.scene.shape.Sphere;


public class HelloNode extends SimpleGame {
  public static void main(String[] args) {
    HelloNode hellonode = new HelloNode();
    hellonode.setConfigShowMode(ConfigShowMode.AlwaysShow);
    hellonode.start();
  }

  @Override
  protected void simpleInitGame() {
    // TODO Auto-generated method stub
    Box b = new Box("My Box"new Vector3f(000), new Vector3f(111));
    b.setModelBound(new BoundingSphere());
    // Calculate the best bounds for the object you gave it
    b.updateModelBound();
    
    b.setLocalTranslation(new Vector3f(020)); 
    
    b.setRandomColors();
    /////////////////////////////////////////////////////////
    Sphere s = new Sphere("My sphere"10101f); 
    
    s.setModelBound(new BoundingBox());
    
    s.updateModelBound();
    // Give the sphere random colors
    s.setRandomColors();
 
    Node n = new Node("My Node");
    n.attachChild(b);
    n.attachChild(s);
    // Make the node and all its children 5 times larger.
    n.setLocalScale(2);
      
    rootNode.setLightCombineMode(Spatial.LightCombineMode.Off);//광원효과
    
    rootNode.attachChild(n);





  }

}
=========================================================================


======================================================================
http://www.jmonkeyengine.com/wiki/doku.php/tutorial_2_-_learning_jme_2 
자세한 내용은 저 홈페이지에 있다.
=====================================================================
=====================================================================
package net.itisn;
class company
{
  private Manag m1, m2;
  private Arbriter a1, a2;
  private Employee e1, e2;
  protected Employee Em[];
  
  public company()
  {
  
  m1 = new Manag("홍길동","1번 ","영국");
  m2 = new Manag("기분파","2번 ","프랑스");
  a1 = new Arbriter("장발장");
  a2 = new Arbriter("일지매");
  e1 = new Employee("사람","3번");
  e2 = new Employee("인간","4번");
  
  Em = new  Employee[6];
  Em[0]=m1;
  Em[1]=m2;
  Em[2]=a1;
  Em[3]=a2;
  Em[4]=e1;
  Em[5]=e2;
  }
  public void makeMoney() {
    int n = Em.length;
    for(int i=0; i < n; i++) {
      Em[i].work();
    }
  }

}
class Employee
{
  protected String name;
  protected String Enum;
  protected String title;
  protected int num;
  protected int length;
  public Employee(String name)
  {
    this.name=name;
    
  }
  public Employee(String name, String Enum)
  {
    this.name=name;
    this.Enum=Enum;
  }
  public void title(String title)
  {
    this.title=title;
  }
  public void num(int num)
  {
    this.num= num;
  }
  public void work()
  {
    System.out.println("지금"+name+Enum+"(이)가 일하고있습니다.");
  }
  

}
class Manag extends Employee
{
  private String Dept; //부서
  public Manag(String name, String Enum,String Dept) {
    super(name, Enum);
    this.Dept=Dept;
    
  }
  public void work()
  {
    System.out.println("매니저 "+name +"가 일하고있습니다."+Dept+"나라사람이");
  }
  
}
class Arbriter extends Employee
{
  private String addr;
  public Arbriter(String name, String Enum) {
    super(name, Enum);
  
  
  }
  public Arbriter(String name) {
    super(name);
  
    
  }
  public void work()
  {
    System.out.println("아르바이트 학생입니다.");
  }
}

public class ManagerTest {

  /**
   * @param args
   */

  public static void main(String[] args) {
    company  mycom = new company();
    mycom.makeMoney();


  }

}