Java - Practica
Java - Practica
FACULTAD DE INGENIERÍA
PROGRAMACIÓN EN JAVA Y LAB.
SEMESTRE: Séptimo
1.- CODIGO
CODIGO 1 - PAQUETE
package practica_4;
import fiuras.telec.edu.cuadrado;
public class Practica_4 {
public static void main(String[] args) {
new inicio().setVisible(true);
} }
CODIGO 2 – CLASE 1
private void jbtCalcularActionPerformed(java.awt.event.ActionEvent evt) {
cuadrado c =new cuadrado();
c.setLado(Integer.parseInt(jtfLado.getText()));
jtfPerimetro.setText(String.valueOf(c.perimetro()));
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
pág. 1
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(inicio.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(inicio.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(inicio.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(inicio.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
CODIGO 3 – CLASE 2
package fiuras.telec.edu;
public abstract class figura {
private String color;
public void setColor (String cl){
this.color=cl; }
public String getColor(){
return color;}
public abstract int perimetro();
}
CODIGO 4 – CLASE 3
package fiuras.telec.edu;
public class cuadrado extends figura{
private int lado;
public void setLado (int ld){
this.lado=ld;}
public int getLado(){
return lado;}
public int perimetro(){
return lado*4;}
}
2.- INTERFAS
pág. 2
pág. 3