DONCELLA

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Ejercicio1;
import java.util.Scanner;


/**
 *
 * @author INGENIERIA
 */
public class ProyectoColas {

    public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    Cola<Doncella> cola=new Cola();
    Doncella doncella;
    String nombre;
    boolean encontrado=false;
    int talla;
    int x=0;
    int da;
    System.out.print("Ingrese numero de doncellas");
    int num=sc.nextInt();
    while(x<num){
        System.out.print("Nombre");
        nombre=sc.next();
        System.out.println("Talla");
        talla=sc.nextInt();
        doncella=new Doncella(nombre, talla);
        cola.encolar(doncella);
        x++;
    }
    String no = "";
    System.out.println("Ingrese talla a buscar");
    talla=sc.nextInt();
    while(!cola.esVacia() && !encontrado){
       doncella=cola.desencolar();
       if(doncella.getTalla()==talla){
        no=doncella.getNombre();
           encontrado=true;
       }
    }
    if(encontrado){
        System.out.println("La doncella es "+no);
    }else{
        System.out.println("No se encontro la doncella");
    }
    }

}


CLASE DONCELLA
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Ejercicio1;

/**
 *
 * @author INGENIERIA
 */
public class Doncella {
   private String nombre;
    private int talla;
    public Doncella(String nombre, int talla){
        this.nombre=nombre;
        this.talla=talla;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public int getTalla() {
        return talla;
    }

    public void setTalla(int talla) {
        this.talla = talla;
    }
    
}




No hay comentarios.:

Publicar un comentario

Buscar este blog