Page 1 of 1

PS #4

Posted: Sat Oct 16, 2010 10:33 am
by angus
Hi, I've been getting some questions about the homework. The idea is that you are using a String as the key to retrieve a List of GeometricShapes.

So, for instance:

Code: Select all

Map<String, List<GeometricShape>> shapeMap = new HashMap<String, List<GeometricShape>>();

List<GeometricShape> circleList = new List<GeometricShape>();
Circle c1 = new Circle(); //pretend this constructor makes a random cricle, you can do something different in your code if you want.
Circle c2 = new Circle();
cricleList.add(c1); //this works because your Circle will extend GeometricShape
circleList.add(c2);
shapeMap.put("Circles", circleList);
When the user selects "Circles" from the GUI (using whatever kind of interface element you want-- a button or a textbox or a drop-down list) that will get the List of circles from the shapeMap:

Code: Select all

List<GeometricShape> currentList = shapeMap.get("Circles");

and then loop through that list and render each circle.

-Angus

Re: PS #4

Posted: Sat Oct 16, 2010 11:29 am
by james
Should we post our homework to a git repo and link it to the forum as before?

Re: PS #4

Posted: Sat Oct 16, 2010 2:54 pm
by angus
Yes, something like <your-initials>-PS4, or you can stick the code in one of your existing repos. -A

Re: PS #4

Posted: Sun Oct 17, 2010 4:15 pm
by Amusesmile
Josh Dickinson:

git@github.com:Amusesmile/JDD-PS4.git

Got the program working and doing what it's supposed to, but I'm not sure the way I did it was very efficient...

Re: PS #4

Posted: Sun Oct 17, 2010 5:19 pm
by tobiast
Download:
git://github.com/thyrrestrup/TT-JavaProcessing-201B.git

Web:
http://github.com/thyrrestrup/TT-JavaProcessing-201B

I have chosen to create a general github repository including all the Java/Processing code done in the 201B class.
The repository also includes the Interactive Geometrics - Problem Set 4.

Re: PS #4

Posted: Mon Oct 18, 2010 12:54 am
by mhetrick
Download:
git://github.com/mhetrick/MH-ShapeDrawer.git

Run the included -bash script to compile and open.

//
If anyone is having trouble drawing Pentagons or Hexagons, I found this wonderful tutorial:
http://processing.org/learning/anatomy/

Re: PS #4

Posted: Mon Oct 18, 2010 8:30 pm
by james
git@github.com:smee2001/JD-PS4.git

My program also feels somewhat lacking in efficiency... Would love to see how the use of Maps and Lists could've been done without the redundancy I had to create in order to fulfill the requirement of the assignment.

Re: PS #4/ cannot debug!!

Posted: Fri Oct 22, 2010 8:17 pm
by Solen
I have uploaded my problem set 4 stuff:
git@github.com:solen/201B-Processing-Sketches-SolenKiratli.git

The problem that it does not work. I do not know why. Any help/comments would be much appreciated.

p.s. I am only trying to get the circles to show up on the screen at this point. If that works, I will add the polygons... I am not worried about the calcArea yet either....

Solen

Re: PS #4

Posted: Sat Oct 23, 2010 12:43 am
by angus
Anyone want to take a stab at debugging Solen's code? -A