Tried to solve the test for abstract classes in Java course. My Code fails in hidden test case #3 and i dont know why. | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

Tried to solve the test for abstract classes in Java course. My Code fails in hidden test case #3 and i dont know why.

https://code.sololearn.com/cQm0f4hg0z9U/?ref=app

22nd May 2021, 9:04 PM
Tom
2 Respostas
+ 1
your are not using the abstraction concept, normally you should extend the classes. class Square extends Shape{....} class Circle extends Shape {....} your code works without that tho. the issue is in double result= this.width*this.width * Math.PI; changing the order of the variables to double result= Math.PI * this.width*this.width; works, I don't know how is it even relevant.
23rd May 2021, 12:08 AM
Bahhaāµ£
Bahhaāµ£ - avatar
+ 1
Damn shoud've seen that. Added "extends Shape " changed the order, Codes works totally fine. Thank you.
23rd May 2021, 6:04 PM
Tom