You are on page 1of 11

ALQUILER DE VEICULOS

Este programa realiza alquiler de carros de turismo y camiones, funciona mediante herencia que
consiste de heredar variables y mtodos de una clase padre a una hija para lo cual e usado dos
clase padres y dos hijas para diferenciar y que se entienda mejor, a continuasion el cdigo
correspondiente:
Clase principal modo main:
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{
// public static void main(String[] args)
System.out.println("TURISMO....!");
//String Cargo, String Departamento,long Cedula, String Nombres, int Edad
turismo bus = new turismo("HINO","hj-345", 2,"CHEBROLET","hj-333", 3);
bus.DatosInformativos();
bus.datos();
System.out.println("CAMIONES....!");
camiones car = new camiones("GMS","df-323",20,"HINO","df-323", 30);
/* car.camion1("df-323", false);
car.camion2("hh-346", false);*/
car.DatosInformativos();
car.datos();
int op;
//tur tu=new tur("MERCEDES","df-323",23,"MAZDA","df-323", 33,false,false,false,false,0);
cami aa=new cami("GMS","df-323",20,"HINO","df-323", 30,false,false,false,false,0);
tur turi=new tur("MERCEDES","df-323",2,"MAZDA","df-323", 3,false,false,false,false,0);
do{
System.out.println("*********ALQUILER DE CAMIONES Y TURISMO*********");
System.out.println("********* 1. ALQUILAR UN CAMION
*********");
System.out.println("+******** 2. ALQUILAR BUS DE TURISMO
*********");
System.out.println("*********
3.DEBOLVER CAMION

*********");
System.out.println("********* 4.DEBOLVER BUS DE TURISMO
*********");
System.out.println("*********
5.IMFORMACION *********");
System.out.println("*********
6.SALIR *********");
op=Integer.parseInt(T.readLine());
switch(op){
case 1:
System.out.println("PRESIONE 1 PARA ALQUILAR CASO CONTRARIO 0");
int a=Integer.parseInt(T.readLine());
aa.al(a);
System.out.println("cual veiculo desea alquilar 1/2");
int aaa=Integer.parseInt(T.readLine());
System.out.println("CON CUANTOS DIAS SALE EL VEICULO");
int aaaa=Integer.parseInt(T.readLine());
aa.definir(aaa,aaaa);
break;
case 2:
System.out.println("PRESIONE 1 PARA ALQUILAR CASO CONTRARIO 0");
int at=Integer.parseInt(T.readLine());
turi.al(at);
System.out.println("cual veiculo desea alquilar 1/2");
int aaat=Integer.parseInt(T.readLine());
System.out.println("CON CUANTOS QUILOMETROS SALE EL VEICULO");
int aaaat=Integer.parseInt(T.readLine());
turi.definir(aaat, aaaat);
break;
case 3:
System.out.println("DESEA DEVOLVER EL VEICULO 1/0");
int e=Integer.parseInt(T.readLine());
aa.devo(e);
System.out.println("CUAL DESEA DEVOLVER 1/2");

int r=Integer.parseInt(T.readLine());
System.out.println("CON CUANTOS DIAS DEVUELVE EL VEICULO");
int rr=Integer.parseInt(T.readLine());
aa.de(r, rr);
break;
case 4:
System.out.println("DESEA DEVOLVER EL VEICULO 1/0");
int ee=Integer.parseInt(T.readLine());
turi.devo(ee);
System.out.println("CUAL DESEA DEVOLVER 1/2");
int tr=Integer.parseInt(T.readLine());
System.out.println("CON CUANTOS KM DEVUELVE EL VEICULO");
int rrr=Integer.parseInt(T.readLine());
turi.de(tr, rrr);
break;
case 5:
System.out.println("/////////INFORMACION DE BUSES DE TURISMO/////////");
turi.DatosInformativos();
turi.datos();
System.out.println("/////////INFORMACION DE CAMIONES/////////////////");
aa.DatosInformativos();
aa.datos();
break;
}
}while(op!=6); }}
Clase padre 1 camion
public class camiones
{ private String marca;
private String matricula;
private int valordia;
private String marca1;
private String matricula1;
private int valordia1;
public camiones(String mar,String matricula, int va,String mar1,String matricula1, int alquilado1) {

this.marca=mar;
this.marca1=mar1;
this.matricula = matricula;
this.valordia = va;
this.matricula1 = matricula1;
this.valordia1 = alquilado1;
}
public void DatosInformativos()
{
System.out.println("camiones");
System.out.println("tipo de bus: " + this.marca);
System.out.println("#1 "+"matricula: " + this.matricula);
System.out.println("valor por dia
$"+this.valordia);
}
public void datos(){
System.out.println("tipo de bus: " + this.marca1);
System.out.println("#2 "+"matricula: " + this.matricula1);
System.out.println("valor por dia"+this.valordia1);
}
}
Clase hija:cami
import java.io.*;
public class cami extends camiones
{
public static InputStreamReader Leer = new InputStreamReader(System.in);
public static BufferedReader Teclado = new BufferedReader(Leer);
private boolean alquilar;
private boolean alquilar1;
private int numeroskm;
private boolean devolver;
private boolean devolver1;
public cami(String mar, String matricula, int va, String mar1, String matricula1, int alquilado1,
boolean alquilar, boolean devolver,boolean alquilar1, boolean devolver1,int nkm) {

super(mar, matricula, va, mar1, matricula1, alquilado1);


this.alquilar = alquilar;
this.alquilar1 = alquilar1;
this.devolver = devolver;
this.devolver1 = devolver1;
this.numeroskm=nkm;
}
public void al(int a){
if(a==1) {
if(this.alquilar==false){
System.out.println("SI SE PUEDE ALQUILAR EL PRIMER CAMION");
}else System.out.println("PRIMER CAMION NO DISPONIBLE");
if(this.alquilar1==false){
System.out.println("SEGUNDO CAMION DISPONIBLE");
}else System.out.println("SEGUNDO CAMION NO DISPONIBLE");
System.out.println("preparando para alquilar");
System.out.println("cual de los veiculos desea alquilar 1/2");
this.DatosInformativos();
this.datos();
}}
public void definir(int maa, int f){
if(maa==1){
if(this.alquilar==false){
System.out.println("SI
escojido");

SE

PUEDE

ALQUILAR

EL

PRIMER

this.alquilar=true;
this.DatosInformativos();
this.numeroskm=f;
}else System.out.println("PRIMER CAMION NO DISPONIBLE");
}
else {
this.numeroskm=0;
if(this.alquilar1==false){
System.out.println("SEGUNDO CAMION DISPONIBLE");

CAMION");System.out.println("a

System.out.println("a escojido");
this.alquilar1=true;
this.numeroskm=f;
this.datos();
}else System.out.println("SEGUNDO CAMION NO DISPONIBLE"); }
}
public void devo(int v){
if(v==1){
if(this.alquilar==true){
System.out.println("desea devolver este camion presione 1");
this.DatosInformativos();}
else if(this.alquilar1==true){
System.out.println(" DESEA DEVOLVER ESTE CAMION PRESIONE 2");
this.datos();}
}}
public void de(int devol,int d){
int valor=0;
if(devol==1){
this.alquilar=false;
System.out.println("SU CAMION ESTA CIENDO DEVOLVIDO");
valor=(d-this.numeroskm)*20;
System.out.println("SU CUENTA A PAGAR ES..."+valor+"$");
}else{ this.alquilar1=false;
System.out.println("SU CAMION ESTA CIENDO DEVOLVIDO");
valor=(d-this.numeroskm)*40;
System.out.println("SU CUENTA A PAGAR ES..."+valor+"$");
}
}
@Override
public void datos() {
super.datos();
if(this.alquilar1==true){
System.out.println(" YA ESTA ALQUILADO");
System.out.println("arranco con

"+this.numeroskm+" dias");
}
else System.out.println("DISPONIBLE");
}
@Override
public void DatosInformativos() {
super.DatosInformativos();
if(this.alquilar==true){
System.out.println(" YA ESTA ALQUILADO");
System.out.println("arranco con
"+this.numeroskm+" dias");
}
else System.out.println("DISPONIBLE");
}
}
Clase padre turismo:
public class turismo
{
private String marca;
private String matricula;
private int alquilado;
private String marca1;
private String matricula1;
private int alquilado1;
public turismo(String marca,String matricula, int alquilado,String marca1,String matricula1, int
alquilado1) {
this.marca=marca;
this.matricula = matricula;
this.alquilado = alquilado;
this.marca1=marca1;
this.matricula1 = matricula1;
this.alquilado1 = alquilado1;
}
public void DatosInformativos()

{
System.out.println("buses para turismo");
System.out.println("tipo de bus: " + this.marca);
System.out.println("#1 "+"matricula: " + this.matricula);
System.out.println("valor por KM
$"+this.alquilado);
}
public void datos(){
System.out.println("tipo de bus: " + this.marca1);
System.out.println("#2 "+"matricula: " + this.matricula1);
System.out.println("valor por KM"+this.alquilado1);
}
}
Clase hijo turi:
public class tur extends turismo
{
private boolean alquilar;
private boolean alquilar1;
private int numeroskm;
private boolean devolver;
private boolean devolver1;
public tur(String marca, String matricula, int alquilado, String marca1, String matricula1, int
alquilado1, boolean alquilar, boolean alquilar1, boolean devolver, boolean devolver1,int
numeroskm) {
super(marca, matricula, alquilado, marca1, matricula1, alquilado1);
this.alquilar = alquilar;
this.alquilar1 = alquilar1;
this.numeroskm = numeroskm;
this.devolver = devolver;
this.devolver1 = devolver1;
}
public void al(int a){
if(a==1) {
if(this.alquilar==false){

System.out.println("SI SE PUEDE ALQUILAR EL PRIMER CAMION");


}else System.out.println("PRIMER CAMION NO DISPONIBLE");
if(this.alquilar1==false){
System.out.println("SEGUNDO CAMION DISPONIBLE");
}else System.out.println("SEGUNDO CAMION NO DISPONIBLE");
System.out.println("preparando para alquilar");
System.out.println("cual de los veiculos desea alquilar 1/2");
this.DatosInformativos();
this.datos();
}}
public void definir(int maa, int f){
if(maa==1){
if(this.alquilar==false){
System.out.println("SI SE PUEDE ALQUILAR EL PRIMER CAMION");
System.out.println("a escojido");
this.alquilar=true;
this.numeroskm=f;
this.DatosInformativos();
}else System.out.println("PRIMER CAMION NO DISPONIBLE");
}
else {
this.numeroskm=0;
if(this.alquilar1==false){
System.out.println("SEGUNDO CAMION DISPONIBLE");
System.out.println("a escojido");
this.alquilar1=true;
this.numeroskm=f;
this.datos();
}else System.out.println("SEGUNDO CAMION NO DISPONIBLE"); }
}
public void devo(int v){
if(v==1){
if(this.alquilar==true){
System.out.println("desea devolver este camion presione 1");

this.DatosInformativos();}
else if(this.alquilar1==true){
System.out.println(" DESEA DEVOLVER ESTE CAMION PRESIONE 2");
this.datos();}
}}
public void de(int devol,int d){
int valor=0;
if(devol==1){
this.alquilar=false;
System.out.println("SU CAMION ESTA CIENDO DEVOLVIDO");
valor=(d-this.numeroskm)*2;
System.out.println("SU CUENTA A PAGAR ES..."+valor+"$");
}else{ this.alquilar1=false;
System.out.println("SU CAMION ESTA CIENDO DEVOLVIDO");
valor=(d-this.numeroskm)*3;
System.out.println("SU CUENTA A PAGAR ES..."+valor+"$");
}
}
@Override
public void datos() {
super.datos();
if(this.alquilar1==true){
System.out.println(" YA ESTA ALQUILADO");
System.out.println("arranco con
"+this.numeroskm+" KM");
}
else System.out.println("DISPONIBLE");
}
@Override
public void DatosInformativos() {
super.DatosInformativos();
if(this.alquilar==true){
System.out.println(" YA ESTA ALQUILADO");
System.out.println("arranco con

"+this.numeroskm+" KM");
}else System.out.println("DISPONIBLE");}}

You might also like