+ 5
I need helppp!
Read my code and teach me what is wrong https://code.sololearn.com/cHTJJZi2d6ST/?ref=app
18 Respostas
+ 2
| €(8,8)
|
|
|
| €(5,5)
|
| €(3,3)
|
|_____________________________________
+ 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.
+ 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.
+ 1
It might be that the package is not supported by SoloLearn
+ 1
I am not all that good with Java even if I have basics, what is the error shown ?
+ 1
then what is the problem ?
+ 1
Describe exactly what you want main to do.
+ 1
Let me try again to write the code and update.
+ 1
Thanks guys!
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
0
please use the pc
0
ok but just see my code
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)
0
If you run the program the output is
(null)-->(null)
0
Could you show me the correct?
0
print a line as (3,3)-->(5,5) when i insert them
0
Change default constructor so that it gives the values you want for your points I guess
- 1
I am on my phone and can't go to my PC ... Sorry ...