• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sierpinski Triangle Question (very quick)

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?):



 
Rancher
Posts: 1044
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


 
Skool. Stay in. Smartness. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic