Advertisement
RiversMakris

Clase4.java

Aug 18th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.64 KB | None | 0 0
  1. public class Clase4{
  2.  
  3.   public static void main(String[] args){
  4.  
  5.     //objects Pantalla
  6.     //received paramater from the constructor on Class Pantalla
  7.     Pantalla pantalla = new Pantalla(5);
  8.     Pantalla pantalla2 = new Pantalla(5);
  9.     //False because even though they have the same data they are different
  10.     System.out.println(pantalla == pantalla2)
  11.     //Objects Celular iPhone and Galaxy
  12.     /* Question: why did we wrote pantalla? I know that the String is there
  13.      because of the constructor on the Celular Class, String modelo but what's the
  14.      Pantalla pantalla?  */
  15.     Celular iPhone = new Celular(" iPhone X ", pantalla);
  16.     Celular galaxy = new Celular(" Galaxy S9 ", pantalla);
  17.     /* Question: From where does the iPhone.getPantalla() comes from?
  18.     what are we doing here? */
  19.     System.out.println(pantalla == iPhone.getPantalla())
  20.     //Here we are using the objects with the behaviours, nothing complicated
  21.     pantalla.encenderse();
  22.     pantalla2.encenderse();
  23.     //Third object but what does the iPhone.getPantalla(); do?
  24.     //If it's an object why we didn't wrote new?
  25.     Pantalla pantalla3 = iPhone.getPantalla();
  26.     //Apart from whatever iPhone.getPantalla() does we added the
  27.     //.encenderse(); so it does whatever is supposed to do?
  28.     pantalla3.encenderse();
  29.      //Here I have no idea what's going on...
  30.     iPhone.getPantalla().encenderse();
  31.     System.out.println(iPhone.getPantalla().getTamanio());
  32.     System.out.println(pantalla == pantalla3);
  33.  
  34.     galaxy.getPantalla().romper();
  35.     System.out.println(pantalla.getTamanio());
  36.     System.out.println(iPhone.getPantalla().getTamanio());
  37.   }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement