#Looking for somebody that would like to help me with some simple POO JAVA exercises!
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
@languid steppe what's the problem?
Many xd
for example
unexpected message fdrom get.Message
But actually it is all, I dont get how to do it with the information I get provided by my teachers
i don't understand what you mean, could you post the error?
OMW
// 3.- Instanciación de tres objetos Bombilla
System.out.println("Creación de bombillas (constructores)");
System.out.println("-------------------------------------");
// 3.1.- Intento de crear una bombilla encendida con una potencia no válida (hay que gestionar la posible excepción)
try {
bombilla1 = new Bombilla(true, 250);
} catch (IllegalArgumentException e) {
System.out.println("Error: " + e.getMessage());
} ` `
Sorry its on spanish...
lemme try again
System.out.println("Creación de bombillas (constructores)");
System.out.println("-------------------------------------");
// 3.1.- Intento de crear una bombilla encendida con una potencia no válida (hay que gestionar la posible excepción)
try {
bombilla1 = new Bombilla(true, 250);
} catch (IllegalArgumentException e) {
System.out.println("Error: " + e.getMessage());
}```
Detected code, here are some useful tools:
// 3.- Instanciación de tres objetos Bombilla
System.out.println("Creación de bombillas (constructores)");
System.out.println("-------------------------------------");
// 3.1.- Intento de crear una bombilla encendida con una potencia no válida (hay que gestionar la posible excepción)
try {
bombilla1 = new Bombilla(true, 250);
} catch (IllegalArgumentException e) {
System.out.println("Error: " + e.getMessage());
}
Detected code, here are some useful tools:
Detected code, here are some useful tools :
e is basically an object of type IllegalArguementException, e.message is there to tell you the error message that is associated with that particular error
for ex: if you see that try block in your code, while creating Bombilla object, now if say any in valid arugement is passed then this exception will occur and e.message will basically give you more information about the error
@languid steppe are you familiar with exceptions?
not very much, but I guess it is good
because
In my case it refers to another methor
method
its only I thought i had a mistake becasue the output is pretty weird
@languid steppe ok message is a just a method that's meant to display error in a more readable way of said exception
you should read about exceptions, basically anything goes wrong you get an exception. You may have already encountered other excpetions in your console when you type wrong syntax or code doesnt work.
for ex: Here i created an array with 3 integer elements, first i tried to access element with index 1 and if you see on right side there "2" printed as output. But when i do something java doesnt like for ex: accessing 4th element in an array which only has 3 elements, it throws an exception "ArrayIndexOutOfException"
now we can handle exceptions, what does that mean? it means whenever an exception occurs what do we do? that's when we use try-catch block
we put code that could generate an exception in our try block, if everything goes right the code works fine. If an exception is caught, itll execute the catch block
and do whatever's in there