Professional Documents
Culture Documents
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Pru;
/**
*
* @author HELLEN
*/
import java.awt.*;
import java.applet.*;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Pru;
/**
*
* @author HELLEN
*/
import java.awt.*;
import java.applet.*;
SUMA +
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Pru;
/**
*
* @author HELLEN
*/
import java.awt.*;
import java.applet.*;
RESTA
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Pru;
/**
*
* @author HELLEN
*/
import java.awt.*;
import java.applet.*;
CONVERSION
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Conversion;
/**
*
* @author HELLEN
*/
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public Conversion()
{
l1 = new Label("Centgrados");
t1 = new TextField();
l2 = new Label("Fahrenheit");
t2 = new TextField();
b = new Button("Calcula");
add(l1);
add(t1);
add(l2);
add(t2);
add(b);
b. addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
double num = Double.parseDouble(t1.getText());
t2.setText(""+((9.0/5.0*num)+32));
}
}
CUADRADO
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public AppletDaCuadrado()
{
t = new TextField(); // se crea el objeto texto
b = new Button("Calcula"); // se crea el boton para calcular
add(t); // se aade el texto a la pantalla
add(b); // se aade el botn a la pantalla
b. addActionListener(this); // se le aade al boton la facilidad de ser escuchado
}
CUADRADO
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Cuadrado;
/**
*
* @author HELLEN
*/
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.lang.Math;
CUADRATICA
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Cuadratica;
/**
*
* @author HELLEN
*/
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.lang.Math;
public Cuadratica()
{
l1 = new Label("a");
t1 = new TextField();
l2 = new Label("b");
t2 = new TextField();
l3 = new Label("c");
t3 = new TextField();
l4 = new Label("Raiz1");
t4 = new TextField();
l5 = new Label("Raiz2");
t5 = new TextField();
b = new Button("Calcular");
add(l1);
add(t1);
add(l2);
add(t2);
add(l3);
add(t3);
add(l4);
add(t4);
add(l5);
add(t5);
add(b);
b. addActionListener(this);
}
2. QU ES UN OBJETO EN LA POO?
Un objeto es cualquier cosa que cumpla con cualquier funcin u
operaciones con las cuales se pueden definir el comportamiento y el
estado de dicho objeto.
3. QU DIFERENCIA EXISTE ENTRE UN TIPO DE DATO PRIMITIVO Y UN TIPO
DE DATO OBJETO?
RANGO
NOMBRE TIPO OCUPA
APROXIMADO
Carcter
char 2 bytes ---
simple
Valor true o
boolean 1 byte ---
false
TIPOS
DE
DATOS String (cadenas de texto)
Tipos de la biblioteca
EN JAVA Muchos otros (p.ej. Scanner, TreeSet,
estndar de Java
ArrayList)
Character
Boolean