♫♫♫♫ PROYECTO Nº 2♫♫♫ Con HERENCIA



1.- DESARROLLAR UN PROGRAMA JAVA PARA UNA AGENCIA DE ALQUILER DE CAMIONES PARA TURISMO

Principal
import java.io.*;
public class Principal {
public static InputStreamReader L=new InputStreamReader(System.in);
public static BufferedReader T=new BufferedReader(L);
    public static void main(String[] args) throws IOException{
    cami t=new cami("Tucson","jj-28",false,0,false);
cami t1=new cami("Mazda","nn-99",false,0,false);
 tur tu=new tur("Vitara","gf-234",false,0,false);
 tur tu1=new tur("Chevrolet luv","ss-465",false,0,false);
   boolean jj=false;
   boolean jj1=false;
   boolean tur=false;
   boolean tur1=false;
 int op;
              do{
         System.out.println("ªªªªSe alquila camiones para turismoªªªª");
         System.out.println("ªªªª1.ALQUILAR UN CAMIONªªªªªªªªªªªªªªªª");
         System.out.println("ªªªª2.ALQUILAR BUS DE TURISMOªªªªªªªªªªª");
         System.out.println("ªªªª3.ENTREGA DEL CAMIONªªªªªªªªªªªªªªªª");
         System.out.println("ªªªª4.ENTREGA BUS DE TURISMOªªªªªªªªªªªª");
         System.out.println("ªªªª5.IMFORMATIONªªªªªªªªªªªªªªªªªªªªªªª");
         System.out.println("ªªªª6.EXITªªªªªªªªªªªªªªªªªªªªªªªªªªªªªª");
          op=Integer.parseInt(T.readLine());
                     switch(op){
         case 1:
             t.DatosInformativos();
             t1.DatosInformativos();
                System.out.println("Cual desea 1/2");
 int a=Integer.parseInt(T.readLine());
  if(a==1){
      jj=true;
   System.out.println("Con cuantos dias sale el camion");
  int sa=Integer.parseInt(T.readLine());
   t.definir(sa);
  }
          if(a==2){
      jj1=true;
   System.out.println("Con cuantos dias sale el camion");
  int ssa=Integer.parseInt(T.readLine());
 t1.definir(ssa);
  }
break;
         case 2:
 tu.DatosInformativos();
             tu1.DatosInformativos();
                System.out.println("Cual desea 1/2");
 int as=Integer.parseInt(T.readLine());
  if(as==1){tur=true;
   System.out.println("Con cuantos dias sale el camion");
  int sa=Integer.parseInt(T.readLine());
   tu.definir(sa);
  }
        if(as==2){tur1=true;
   System.out.println("Con cuantos dias sale el camion");
  int ssa=Integer.parseInt(T.readLine());
   tu1.definir(ssa);
  }
break;
               case 3:
              if(jj==true)
                 t.DatosInformativos();
             if(jj1==true)
                 t1.DatosInformativos();
              System.out.println("INGRESE 1 PARA COMENZAR LA ENTREGA");
        int de=Integer.parseInt(T.readLine());
            if ((de==1)&&(jj==true)){
                jj=false;
              System.out.println("DESEA ENTREGAR EL VEHICULO PRESS 1/0");
        int e=Integer.parseInt(T.readLine());
        if(e==1){
            System.out.println("Con cuantos dias es entregado el camion");
        int ee=Integer.parseInt(T.readLine());
                t.de(ee);
             }}
                         if (jj1==true){jj1=false;
             t1.DatosInformativos();
              System.out.println("DESEA ENTREGAR EL VEHICULO PRESS 2/0");
        int e=Integer.parseInt(T.readLine());
        if(e==2){
            System.out.println("CON CUANTOS DIAS ES ENTREGADO");
        int ee=Integer.parseInt(T.readLine());
        t1.de(ee);
             }}
             break;
         case 4:
             if(tur==true)
                 tu.DatosInformativos();
             if(tur1==true)
                 tu1.DatosInformativos();
             System.out.println("INGRESE 1 PARA COMENZAR A ENTREGAR LOS DOS CAMIONES");
        int de5=Integer.parseInt(T.readLine());
             if((de5==1)&& (tur==true)){tur=false;
              System.out.println("DESEA ENTREGAR EL VEHICULO PRESS 1");
        int e=Integer.parseInt(T.readLine());
        if(e==1){
            System.out.println("CON CUANTOS DIAS ES ENTREGADO");
        int ee=Integer.parseInt(T.readLine());
                tu.de(ee);
             }}                     
             if( tur1==true){tur1=false;
              tu1.DatosInformativos();
                    System.out.println("DESEA ENTREGAR EL VEHICULO PRESS 2");
        int e=Integer.parseInt(T.readLine());
        if(e==2){
            System.out.println("CON CUANTOS DIAS ES ENTREGADO");
        int ee=Integer.parseInt(T.readLine());
        tu1.de(ee);
             }}                   
             break;
         case 5:
             System.out.println("/////////INFORMATION DE BUSES DE TURISMO/////////");
            tu.DatosInformativos();
            tu1.DatosInformativos();
                        System.out.println("/////////INFORMATION DE CAMIONES/////////////////");
            t.DatosInformativos();
            t1.DatosInformativos();
             break;
                                   }
        }while(op!=6);
    }
}
Cami
public class cami extends camiones
{
          private boolean alquilar;             
        private int numeroskm;
    private boolean devolver;
    public cami(String marca, String matricula, boolean alquilar, int numeroskm, boolean devolver) {
        super(marca, matricula);
        this.alquilar = alquilar;
        this.numeroskm = numeroskm;
        this.devolver = devolver;
    }
    public void definir( int f){
      if(this.alquilar==false){
        System.out.println("listo para Alquilar");
            System.out.println("A Escogido un Camion");
      this.alquilar=true;
  this.numeroskm=f;
  this.DatosInformativos();
    }else  System.out.println("No se encuentra disponibles ningun camion");
   
public void de(int d){
 int cant=0;
               this.alquilar=false;
          System.out.println("Entregando el camion");
      cant=(d-this.numeroskm)*20;
    System.out.println("El total a pagar es:..."+cant+"$");
       }
    @Override
    public void DatosInformativos() {
        super.DatosInformativos();
         if(this.alquilar){
        System.out.println(" Camion ya escogido");
            System.out.println("arranco con  "+this.numeroskm+"  dias");
    }
   else System.out.println("Si hay camiones para alquilar");
    }
      }
Camiones

public class camiones
{
private String marca; 
     private String matricula;
       public camiones(String marca, String matricula) {
        this.marca = marca;
        this.matricula = matricula;
            }   
   public void DatosInformativos()
    {
     System.out.println("");
      System.out.println("Tipo: " + this.marca);
           System.out.println("Numero de matricula: " + this.matricula);
              }
    }
Tur
public class tur extends camiones
{
  private boolean alquilar;             
        private int numeroskm;
    private boolean entregar;
    public tur(String marca, String matricula,  boolean alquilar, int numeroskm, boolean devolver)
 {
        super(marca, matricula);
        this.alquilar = alquilar;
        this.numeroskm = numeroskm;
        this.entregar = entregar;
    }
    public void definir( int f){
      if(this.alquilar==false){
        System.out.println(" listo para Alquilar");
            System.out.println("A Escogido un Camion");
      this.alquilar=true;
    this.numeroskm=f;
  this.DatosInformativos();
    }else  System.out.println("No se encuentra disponibles ningun camion");
    }       
public void de(int d){
 int cant=0;
            this.alquilar=false;
          System.out.println("Entregando el camion");
      cant=(d-this.numeroskm)*20;
    System.out.println("El total a pagar es:..."+cant+"$");
              }       
    @Override
    public void DatosInformativos() {
        super.DatosInformativos();
        if(this.alquilar==true){
        System.out.println(" Camion ya escogido");
            System.out.println("arranco con  "+this.numeroskm+"  KM");
    }
   else System.out.println("Si hay camiones para alquilar");
          }
}

PANTALLAS DE EJECUCIÓN





















*******************************************************
2.- DESARROLLAR UN PROGRAMA JAVA PARA DE UNA BIBLIOTECA  DONDE ENTRAN Y SALEN LIBROS PRESTADO
Principal


import java.io.*;
public class Principal1 {
public static InputStreamReader L=new InputStreamReader(System.in);
public static BufferedReader T=new BufferedReader(L);
    public static void main(String[] args) throws IOException{      
    int op=0;
          linros dd=new linros("la bella durmiente","edi",5,5,false);
     linros dd1=new linros("oceano","edi2",5,5,false);
         linros dd2=new linros("platero y yo","edi2",5,5,false);
     revista re=new revista("fashion express","desconocido",5,5,false);
     revista re1=new revista("mistica","desconocido",5,5,false);
     revista re2=new revista("nivi","desconocio",5,5,false);
     int veri=0;
    int veri1=0;
     int veri2=0;
    int rev=0;
     int rev1=0;
     int rev2=0;
                 do{
         System.out.println("ªªªªª    BIBLIOTECA  ªªªªªªªªªªªª");
         System.out.println("ªªªªª1.LLEVAR UN BOOKªªªªªªªªªªªª");
         System.out.println("ªªªªª2.LLEVAR UNA REVISTAªªªªªªªª");
         System.out.println("ªªªªª3.ENTREGAR BOOKªªªªªªªªªªªªª");
         System.out.println("ªªªªª4.DEVOLVER REVISTAªªªªªªªªªª");
         System.out.println("ªªªªª5.IMFORMATIONªªªªªªªªªªªªªªª");
         System.out.println("ªªªªª6.EXITªªªªªªªªªªªªªªªªªªªªªª");
          op=Integer.parseInt(T.readLine());
                     switch(op){
         case 1:
                          dd.Datos1();
             dd1.Datos1();
             dd2.Datos1();
             System.out.println("ELIJA EL BOOK QUE PREFIERA");
             System.out.println("INGRESE  1/2/3");
 int a=Integer.parseInt(T.readLine());
 if(a==1){
     veri=1;
 dd.al();
 System.out.println("CUANTAS COPIAS PREFIERE");
 int co=Integer.parseInt(T.readLine());
 dd.definir(co);
 }
  if(a==2){
      veri1=1;
 dd1.al();
 System.out.println("CUANTAS COPIAS PREFIERE");
 int co=Integer.parseInt(T.readLine());
 dd1.definir(co);
 }
  if(a==3){veri2=1;
 dd2.al();
 System.out.println("CUANTAS COPIAS PREFIERE");
 int co=Integer.parseInt(T.readLine());
 dd2.definir(co);
 }
break;
        case 2:
                            re.Datos1();
             re1.Datos1();
             re2.Datos1();
             System.out.println("ELIJA LA REVISTA QUE PREFIERA");
             System.out.println("INGRESE  1/2/3");
 int va=Integer.parseInt(T.readLine());
 if(va==1){rev=1;
 re.al();
 System.out.println("CUANTAS COPIAS PREFIERE");
 int co=Integer.parseInt(T.readLine());
 re.definir(co);
 }
  if(va==2){rev1=1;
 re1.al();
 System.out.println("CUANTAS COPIAS PREFIERE");
 int co=Integer.parseInt(T.readLine());
 re1.definir(co);
 }
  if(va==3){rev2=1;
 re2.al();
 System.out.println("CUANTAS COPIAS PREFIERE");
 int co=Integer.parseInt(T.readLine());
 re2.definir(co);
 }
        break;
               case 3:
   if(veri==1){
   dd.devo();
  veri=2;
   }
   if(veri1==1){
   dd1.devo();
  veri=2; }
   if(veri2==1){
   dd2.devo();
   veri=2; }
   if (veri==2){
      System.out.println("CUANTAS COPIAS VA A ENTREGAR");
 int cop=Integer.parseInt(T.readLine());
   dd.de(cop);}
   if (veri1==2){
      System.out.println("CUANTAS COPIAS VA A ENTREGAR");
 int copy=Integer.parseInt(T.readLine());
   dd1.de(copy);
   }
   if (veri2==2){
      System.out.println("CUANTAS COPIAS VA A ENTREGAR");
 int copi=Integer.parseInt(T.readLine());
   dd2.de(copi);
   }
      break;
  case 4:
             if(rev==1){
   re.devo();
  rev=2;
   }
   if(rev1==1){
   re1.devo();
  rev1=2; }
   if(rev2==1){
   re2.devo();
   rev2=2; }
   if (rev==2){
      System.out.println("CUANTAS COPIAS VA A ENTREGAR");
 int cop=Integer.parseInt(T.readLine());
   re.de(cop);
   }
   if (rev1==2){
      System.out.println("CUANTAS COPIAS VA A ENTREGAR");
 int copy=Integer.parseInt(T.readLine());
   re1.de(copy);
   }
   if (rev2==2){
      System.out.println("CUANTAS COPIAS VA A ENTREGAR");
 int copi=Integer.parseInt(T.readLine());
   re2.de(copi);
   }
                          break;
           case 5:
             System.out.println("/////////INFORMATION DE BOOK/////////");
          dd.Datos1();
          dd1.Datos1();
          dd2.Datos1();
             System.out.println("/////////INFORMATION DE REVISTAS/////////////////");
             re.Datos1();
             re1.Datos1();
                         re2.Datos1();
             break;
                        }
        }while(op!=6);
        }}
Linros
import java.io.*;
public class linros extends publi
{
 public static InputStreamReader Leer = new InputStreamReader(System.in);
 public static BufferedReader Teclado = new BufferedReader(Leer);
              private int numcopias;
            private boolean prestar;
    public linros(String nombre, String editorial, int numcopi, int numcopias,  boolean prestar) {
        super(nombre, editorial, numcopi);
        this.numcopias = numcopias;
              this.prestar = prestar;
          }
    public void al()
{   
          if(this.numcopias>1){
        System.out.println("SI SE PUEDE LEER EN CASA ");
               }else  System.out.println("NO SE PUEDE LEER EN CASA ");
             }
   public void definir( int f){
       if(f<=this.numcopias){
     System.out.println("A ESCOJIDO EL BOOK ");
  this.numcopias-=f;
         this.prestar=true;
  this.Datos1(); 
         }else System.out.println("no hay bastantes copias ");
     }
        public void devo(){
                  if(this.prestar==true){
     this.Datos1(); 
  }  }
          public void de(int d){          
              this.prestar=false;  
      this.numcopias+=d;
       System.out.println("BOOK ENTREGADO A BIBLIOTECA ");
            }
          @Override
    public void Datos1() {
        super.Datos1();
        System.out.println("QUEDAN "+this.numcopias+"BOOK ");
         if(this.numcopias>1)
          System.out.println("BOOK PRESTABLE ");
        else System.out.println("BOOK NO DISPONIBLE ");
           } }
Public
public class publi
{       
    private String nombre;
    private String editorial;
  private int numcopi;

    public publi(String nombre, String editorial, int numcopi) {
        this.nombre = nombre;
        this.editorial = editorial;
        this.numcopi = numcopi;
    }      
   public void Datos1()
    {
     System.out.println("");
      System.out.println("NOMBRE :   " + this.nombre);
           System.out.println("NAME DE LA EDITORIAL: " + this.editorial);
        System.out.println("NUMBER DE PUBLICACIONES:   "+this.numcopi);
              }
   }                                                                                  




3.-
Revista
import java.io.*;
public class revista extends publi
{
    public static InputStreamReader Leer = new InputStreamReader(System.in);
 public static BufferedReader Teclado = new BufferedReader(Leer);
     private int numcopias;
          private boolean prestar;
    public revista(String nombre, String editorial, int numcopi, int numcopias, boolean prestar) {
        super(nombre, editorial, numcopi);
        this.numcopias = numcopias;
        this.prestar = prestar;
    }
        public void al(){    
          if(this.numcopias>1){
        System.out.printn("SI SE PUEDE LEER EN CASA ");
               }else  System.out.println("NO SE PUEDE LEER EN CASA");
              }
   public void definir( int f){
       if(f<=this.numcopias){
     System.out.println("A LLEVADO UN BOOK ");
  this.numcopias-=f;
         this.prestar=true;
  this.Datos1();
        }else System.out.println("No hay bastantes copias ");
     }
        public void devo(){      
         if(this.prestar==true){
     this.Datos1();
   }
    } 
          public void de(int d){
                System.out.println("INGRESE 1 PARA ENTGREGAR ESTE BOOK ");
              this.prestar=false;  
      this.numcopias+=d;
       System.out.println("BOOK ENTREGADO A BIBLIOTECA ");   
      }
     
    @Override
    public void Datos1() {
        super.Datos1();
         System.out.println("QUEDAN "+this.numcopias+"BOOK ");
        if(this.numcopias>1)
          System.out.println("BOOK PRESTABLE ");
        else System.out.println("BOOK DISPONIBLE ");
    }
}
PANTALLAS EN EJECUCION






3.-DESARROLLAR UN PROGRAMA JAVA PARA CONSTRUIR UN ROBOT

PANEL

package robot;
import java.awt.Graphics;
public class Panel extends javax.swing.JPanel {
    private int X=60;
private int Y=68;
private int S=3;
private int H=3;
    public Panel() {
        initComponents();
    }

    @SuppressWarnings("unchecked")



@Override
    public void paint(Graphics g) {
        super.paint(g);
g.drawLine(0, 0, 125, 0);
g.drawLine(0, 25, 125, 25);
g.drawLine(0, 50, 125, 50);
g.drawLine(0, 75, 125, 75);
g.drawLine(0, 100, 125, 100);
g.drawLine(0, 125, 125, 125);

g.drawLine(0, 0, 0, 125);
g.drawLine(25, 0, 25, 125);
g.drawLine(50, 0, 50, 125);
g.drawLine(75, 0, 75, 125);
g.drawLine(100, 0, 100, 125);
g.drawLine(125, 0, 125, 125);
String r="ª";
g.drawString(r, X, Y);
}
public void Izquierda(){
if (this.S>1){
this.S--;
    this.X-=23;
repaint();
}}
public void derecha(){
if (this.S<5){
this.S++;
    this.X+=23;
repaint();
}}
public void arriba(){
if (this.H<5){
this.H++;
    this.Y-=23;
repaint();
}}
public void abajo(){
if (this.H>1){
this.H--;
    this.Y+=23;
repaint();
}}}
package robot;
public class robotpri1 extends javax.swing.JFrame {
         public robotpri1() {
        initComponents();
    } 
    @SuppressWarnings("unchecked")



    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
p1.Izquierda();   
                    }                                        
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
p1.derecha();
        // TODO add your handling code here:
    }                                       
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                        
p1.arriba();
        // TODO add your handling code here:
    }                                    
    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                        
p1.abajo();
        // TODO add your handling code here:
    }                                       
    private void texActionPerformed(java.awt.event.ActionEvent evt) {                                    
String a=this.tex.getText();
    }                                  
    private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
    }                                       
        public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new robotpri1().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                    
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private robot.Panel p1;
    private java.awt.TextField tex;
    // End of variables declaration                  
}

PANTALLAS EN EJECUCIÓN

No hay comentarios:

Publicar un comentario