+ 5

I need helppp!

Read my code and teach me what is wrong https://code.sololearn.com/cHTJJZi2d6ST/?ref=app

20th Sep 2017, 8:34 PM
Ardu
Ardu - avatar
18 Respostas
+ 2
| €(8,8) | | | | €(5,5) | | €(3,3) | |_____________________________________
20th Sep 2017, 8:48 PM
Ardu
Ardu - avatar
+ 6
You'll need to be a bit more descriptive than that. Currently your case 1 doesn't really do anything. Due to it being in a loop and the variable being both declared and instantiated within that loop the Points are created and then destroyed. They are not saved or added to the Polyline anywhere. case 3 just gets an int from the user and doesn't do anything with it. In case 2 you create and print the Polyline, but it doesn't have any Point's to work with. If all you're working on right now is case 2 then you could fix this issue by either creating 2 default Points in the Polylines default constructor or create 2 Points in the switch and create a Polyline with the other constructor. I'm trying to help without changing your program in a way that you don't intend for it to work or one that will help you to solve the issue by yourself by pointing you in the right direction.
20th Sep 2017, 9:51 PM
ChaoticDawg
ChaoticDawg - avatar
+ 3
The only place I see that you're printing out the point is from the switch under case 2 in main. Here you're creating a Polyline that uses the default constructor. Your default constructor is empty so p1 and p2 in the polyline are never initialized, hence they are null.
20th Sep 2017, 9:29 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
It might be that the package is not supported by SoloLearn
20th Sep 2017, 8:35 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 1
I am not all that good with Java even if I have basics, what is the error shown ?
20th Sep 2017, 8:40 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 1
then what is the problem ?
20th Sep 2017, 8:55 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 1
Describe exactly what you want main to do.
20th Sep 2017, 9:35 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Let me try again to write the code and update.
20th Sep 2017, 9:54 PM
Ardu
Ardu - avatar
+ 1
Thanks guys!
20th Sep 2017, 9:54 PM
Ardu
Ardu - avatar
0
make 3 classes 1st class Point.java (copy the index od my code) 2nd class PolyLine.java (copy the code) and main class Main.java
20th Sep 2017, 8:36 PM
Ardu
Ardu - avatar
0
please use the pc
20th Sep 2017, 8:37 PM
Ardu
Ardu - avatar
0
ok but just see my code
20th Sep 2017, 8:38 PM
Ardu
Ardu - avatar
0
Thank you! First of all i insert two points eg (3,3) and (5,5) I want to print the line eg (3,3)-->(5,5) Or if i insert a third point eg (8,8) the result is (3,3)-->(5,5)-->(8,8)
20th Sep 2017, 8:45 PM
Ardu
Ardu - avatar
0
If you run the program the output is (null)-->(null)
20th Sep 2017, 8:55 PM
Ardu
Ardu - avatar
0
Could you show me the correct?
20th Sep 2017, 9:30 PM
Ardu
Ardu - avatar
0
print a line as (3,3)-->(5,5) when i insert them
20th Sep 2017, 9:39 PM
Ardu
Ardu - avatar
0
Change default constructor so that it gives the values you want for your points I guess
20th Sep 2017, 9:42 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
- 1
I am on my phone and can't go to my PC ... Sorry ...
20th Sep 2017, 8:37 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar