#Looking for somebody that would like to help me with some simple POO JAVA exercises!

1 messages · Page 1 of 1 (latest)

languid steppe
#

Very easy exercises, starter level but they are hard for me

errant valeBOT
#

<@&987246399047479336> please have a look, thanks.

errant valeBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

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.

worldly karma
#

@languid steppe what's the problem?

languid steppe
#

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

worldly karma
languid steppe
#

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());
    }```
errant valeBOT
# languid steppe ```// 3.- Instanciación de tres objetos Bombilla System.out.println("Cr...

Detected code, here are some useful tools:

Formatted code
// 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());
}
errant valeBOT
worldly karma
#

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?

languid steppe
#

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

worldly karma
#

@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

languid steppe
#

Yep I get it now!

#

Thanks