-
-
Save pablovillacanas/6390e479f747d62d19942f70bee7c5d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Main { | |
| public static void main(String[] args) { | |
| Scanner scanner = new Scanner(System.in); | |
| System.out.println("Seleccione el Electrodoméstico que desea comprar: \n" | |
| + "1- Nevera" | |
| + "2- Lavadora" | |
| + "3- Microondas"); | |
| int opcion = scanner.nextInt(); | |
| Electrodoméstico electr = null; | |
| switch (opcion) { | |
| case 1: | |
| electr = new Nevera(); | |
| break; | |
| case 2: | |
| electr = new Lavadora(); | |
| break; | |
| case 3: | |
| electr = new Microondas(); | |
| break; | |
| default: | |
| break; | |
| } | |
| System.out.println("Ha comprado usted un electrodoméstico de tipo: " + electr); | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment