±Û¾´ÀÌ :ÇÑÇöÀÏ 2000³â 5¿ù 31ÀÏ 15:20:01
ÀÚ¹ÙÀÇ °´Ã¼¸¦ ÀÌ¿ëÇÏ·Á´Âµ¥ ¾î·Æ±º¿ä..
¾Æ¿ï·¯ ¹öÆ°À» 1¹ø ´©¸£¸é ÀÌ°Ô ³ª¿À±¸ ´Ù½Ã ´©¸£¸é ´Ù¸¥°Ô ¶Ç ´©¸£¸é ´Ù¸¥°Ô ³ª¿À°Ô ÇÏ´Â ¹ýµÎ¿ä...
¹Ø¿¡ ÀÖ´Â °ÍµéÀÌ Á¦°¡ ÇѰǵ¥...
¿¡·¯¸¸ ³ª±¸ Àß ¸ð¸£°Ú±º¿ä....
°è¼Ó ¹°¾î º¸±âµµ ¹Ì¾ÈÇؼ¿ä.....
ºÎŹµå¸³´Ï´Ù.....
package test;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Rectangle;
public class hhh1 extends Applet{
TextField text=new TextField();
Button but;
hhh q;
q=new hhh();
q.a=6;
q.b=3;
q.result=getresult() ;
public void init() {
setLayout(null);
setBounds(0,0,500,200);
Rectangle x=new Rectangle(10,10,100,23);
text.setBounds(x);
add(text);
but=new Button("cal");
Rectangle z=new Rectangle(130,10,70,23);
but.setBounds(z);
but.addActionListener(new actionListener());
add(but);
}
class actionListener implements ActionListener{
public void actionPerformed(ActionEvent evt){
Button obj=(Button)evt.getSource();
if(obj==but){
text.setText(a+b +" = "+hhh.add(getResult()));
}
if(obj==but){
text.setText(a-b +" = "+hhh.min(getResult()));
}
if(obj==but){
text.setText(a*b +" = "+hhh.mult(getResult()));
}
if(obj==but){
text.setText(a/b +" = "+hhh.divide(getResult()));
}
}
}
}
¶Ç Çϳª´Â
package test;
public class hhh {
public int a;
public int b;
public int result;
public hhh(int a,int b){
this.a=a;
this.b=b;
}
public void add(){
result=a+b;
}
public void min(){
result=a-b;
}
public void mult(){
result=a*b;
}
public void divide(){
result=a/b;
}
public int getResult(){
return result;
}
}
ÀÔ´Ï´Ù...
¼ÕÁ» ºÁÁÖ¼¼¿ä... ºÎŹÀÔ´Ï´Ù..