Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Sierpinski Triangle Question (very quick)  RSS feed

 
Jonny Carterson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I am stuck at a part in this triangle creation. I need to add X from the random to X from the last point in the arrayList and add Y from the random to Y from the last point in the arrayList. I tried using "getX()" and "getY()" to try to get the coordinate from the arraylist, but I am having no luck.

I am stuck and don't know how to get the index of the last X coordinate or the Y coordinates.

So pretty much this is my trouble (as in I know how to get new random points, but how do I add these new x and y points to the last point and then divide them in half?):



 
Ivan Jozsef Balazs
Rancher
Posts: 999
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> ArrayList<Point> randomPoints

So randomPoints is an ArrayList, an ArrayList is a List and has this method: size()



So if a List has at least one element, the last one can be obtained as


 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!