gonzalob

Untitled

May 26th, 2021
1,219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.70 KB | None | 0 0
  1. package app;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. public class Main {
  7.  
  8.     public static void main(String[] args) {
  9.         // TODO Auto-generated method stub
  10.        
  11.         Caja caja = new Caja();
  12.         caja.agregar(new Gato());
  13.         caja.agregar(new Caramelo());
  14.         caja.agregar(new Perro());
  15.        
  16.         CajaV2<String,Integer> cajaV2= new CajaV2<>();
  17.         cajaV2.setUnaVariable("pepe");
  18.         System.out.println(cajaV2.getUnaVariable());
  19.         cajaV2.vaciarVariable();
  20.        
  21.        
  22.        
  23.         CajaV2<Gato,Perro>cajaV2_gatos = new CajaV2<>();
  24.         cajaV2_gatos.setUnaVariable(new Gato());
  25.         cajaV2_gatos.vaciarVariable();
  26.        
  27.         EntradaMapa<String, Perro> entradaMapa;
  28.        
  29.         EntradaMapaAlumno<String, Alumno> entradaMapaAlumno = new EntradaMapaAlumno();
  30.         entradaMapaAlumno.getClave();
  31.        
  32.         metodoLargo(1,2);
  33.        
  34.         Alumno alumno = new Alumno(12);
  35.         Alumno otroAlumno = new Alumno(100);
  36.        
  37.         Docente docente = new Docente(5);
  38.         Docente docente2 = new Docente(5);
  39.        
  40.         System.out.println(compararDosAlgos(alumno, otroAlumno));
  41.         System.out.println(compararDosAlgos(docente, docente2));
  42.        
  43.         //compararDosAlgos(new Perro(), new Perro()); No acepta!
  44.        
  45.    
  46.        
  47.         try
  48.         {
  49.             List<String> aaa = new ArrayList<String>();
  50.             //aaa.get(60);
  51.            
  52.         }
  53.        
  54.         catch (NullPointerException error)
  55.         {
  56.             //error.printStackTrace();
  57.             //System.out.println(error.getMessage());
  58.             System.out.println("NullPointerException");
  59.         }
  60.        
  61.         catch (Exception error)
  62.         {
  63.             error.printStackTrace();
  64.             //System.out.println(error.getMessage());
  65.             System.out.println("Exception "+error.getMessage());   
  66.         }
  67.        
  68.         finally
  69.         {
  70.             System.out.println("fin"); 
  71.         }
  72.        
  73.        
  74.         try {
  75.             superLogin();
  76.  
  77.         } catch (Exception e) {
  78.             // TODO Auto-generated catch block
  79.             System.out.println("Exception "+e.getMessage());   
  80.         }
  81.        
  82.        
  83.     }
  84.    
  85.     public static <T extends Number> boolean metodoLargo(T unaVariable, T otraVariable)
  86.     {
  87.         boolean esMayor = false;
  88.        
  89.         if (unaVariable.intValue() > otraVariable.intValue())
  90.         {
  91.             esMayor = true;
  92.         }
  93.        
  94.         return esMayor;
  95.     }
  96.    
  97.     public static <T extends Comparable<T>> int compararDosAlgos(T unaCosa, T otraCosa)
  98.     {
  99.         return unaCosa.compareTo(otraCosa);
  100.     }
  101.    
  102.     public static void superLogin()
  103.     {
  104.         try {
  105.             login("","sdasdas");
  106.            
  107.         }
  108.         catch (NullPointerException e) {
  109.             // TODO Auto-generated catch block
  110.             e.printStackTrace();
  111.         }
  112.         catch (Exception e) {
  113.             // TODO Auto-generated catch block
  114.             e.printStackTrace();
  115.         }
  116.     }
  117.    
  118.     public static void login(String usuario, String contra) throws Exception,NullPointerException
  119.     {
  120.         if (usuario == null)
  121.         {
  122.             throw new NullPointerException("sasdasd");
  123.         }
  124.         if (usuario.isEmpty())
  125.         {
  126.             throw new Exception("usuario vacio");
  127.         }
  128.     }
  129.  
  130. }
  131.  
Advertisement
Add Comment
Please, Sign In to add comment