PS #4

Post Reply
angus
Posts: 43
Joined: Fri Apr 02, 2010 1:54 pm

PS #4

Post by angus » Sat Oct 16, 2010 10:33 am

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

james
Posts: 12
Joined: Thu Apr 08, 2010 10:07 am

Re: PS #4

Post by james » Sat Oct 16, 2010 11:29 am

Should we post our homework to a git repo and link it to the forum as before?

angus
Posts: 43
Joined: Fri Apr 02, 2010 1:54 pm

Re: PS #4

Post by angus » Sat Oct 16, 2010 2:54 pm

Yes, something like <your-initials>-PS4, or you can stick the code in one of your existing repos. -A

Amusesmile
Posts: 10
Joined: Fri Sep 24, 2010 1:26 pm

Re: PS #4

Post by Amusesmile » Sun Oct 17, 2010 4:15 pm

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...

tobiast
Posts: 6
Joined: Fri Sep 24, 2010 3:25 pm

Re: PS #4

Post by tobiast » Sun Oct 17, 2010 5:19 pm

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.

mhetrick
Posts: 15
Joined: Sat Sep 25, 2010 7:08 pm

Re: PS #4

Post by mhetrick » Mon Oct 18, 2010 12:54 am

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/

james
Posts: 12
Joined: Thu Apr 08, 2010 10:07 am

Re: PS #4

Post by james » Mon Oct 18, 2010 8:30 pm

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.

Solen
Posts: 5
Joined: Mon Apr 12, 2010 10:16 am

Re: PS #4/ cannot debug!!

Post by Solen » Fri Oct 22, 2010 8:17 pm

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

angus
Posts: 43
Joined: Fri Apr 02, 2010 1:54 pm

Re: PS #4

Post by angus » Sat Oct 23, 2010 12:43 am

Anyone want to take a stab at debugging Solen's code? -A

Post Reply