Código:
class Pill {
int quantity = 0;
int priority = 0;
String name;
void changeQuantity(int newValue) {
quantity = newValue;
}
void changePriority(int newValue) {
priority = newValue;
}
void changeName(String newValue) {
name = newValue;
}
}
class Tramadol extends Pill {
}
class Alprazolam extends Pill {
}
class PillsApp {
public static void main (String[] args) {
Pill Tramadol = new Pill();
Pill Alprazolam = new Pill();
Tramadol.changeQuantity(20);
Tramadol.changePriority(1);
Tramadol.changeName("Trama-Klosidol");
Alprazolam.changeQuantity(10);
Alprazolam.changePriority(2);
Alprazolam.changeName("Alplax");
System.out.println(Tramadol.name + " es numero " + Tramadol.priority);
System.out.println("La cantidad que viene es " + Tramadol.quantity + " por caja");
System.out.println(Alprazolam.name + " es numero " + Alprazolam.priority);
System.out.println("La cantidad que viene es " + Alprazolam.quantity);
}
}
Código:
$ java PillsApp Trama-Klosidol es numero 1 La cantidad que viene es 20 por caja Alplax es numero 2 La cantidad que viene es 10





Comentario