Presentation is loading. Please wait.

Presentation is loading. Please wait.

Recitation 5 September 23, 2011. As you come in...  Please sit next to someone you will collaborate with for today’s recitation.  Choose someone with.

Similar presentations


Presentation on theme: "Recitation 5 September 23, 2011. As you come in...  Please sit next to someone you will collaborate with for today’s recitation.  Choose someone with."— Presentation transcript:

1 Recitation 5 September 23, 2011

2 As you come in...  Please sit next to someone you will collaborate with for today’s recitation.  Choose someone with whom you have NOT collaborated during a previous recitation.

3 Announcements  Object Editor 18 available on course website  Remove Object Editor jar file from all submissions  Compress & crop images in Word files  Capitalize class & package names correctly

4 Today’s Goals:  Create a composite graphics object  Display graphics in ObjectEditor  Get some practice with test-first programming

5 Graphics  A class can be interpreted as a basic graphics object if it follows a set of rules  Naming conventions  Interface conventions  Can create composite graphics objects  Class has a logical structure that contains properties of a line, circle, etc.

6 Object Editor Point Rules  An object is recognized as a point representation if:  Its interface or class has the string “Point” in its name  It has integer properties, x and y, representing cartesian coordinates public interface Point { public int getX(); public int getY(); }

7 Object Editor Line Rules  An object is recognized as a rectangle/line/oval if:  Its interface or class has the string “Rectangle” / “Oval” / “Line” in its name  It has properties describing the bounding box of the shape public interface Line { public Point getLocation(); public int getWidth(); public int getHeight(); }

8 Composite Graphical Objects  Compose the existing geometric objects into a logically structured object  Recall the cartesian plane example public interface CartesianPlane{ public Line getXAxis(); public Line getYAxis(); public Label getXLabel(); public Label getYLabel(); public int getAxesLength(); public void setAxesLength(int length); }

9 Recitation Specification  Download Recitation5.zip from the Recitations page: http://cs.unc.edu/~dewan/comp114/f11/Recitations/ http://cs.unc.edu/~dewan/comp114/f11/Recitations/  Add the Object Editor jar to your Recitation5 project  Create a CartesianTriangle class that implements Triangle  A Triangle is a composite graphics object that consists of three Line objects that share endpoints  The Triangle constructor takes six integers, in this order: x1, y1, x2, y2, x3, y3.  The constructor uses these values to create three Line objects, line1 from (x1,y1) to (x2,y2), line2 from (x2,y2) to (x3,y3), and line3 from (x3,y3) to (x1,y1). NOTE: Order matters!  Define getters for each of the Line objects: getLine1(), getLine2(), and getLine3()

10 Testing for correctness  You can only edit the CartesianTriangle class – editing any other class is forbidden  Recitation5.java contains tests for CartesianTriangle  Your implementation is correct if you can run Recitation5 and get “All tests passed” and this:


Download ppt "Recitation 5 September 23, 2011. As you come in...  Please sit next to someone you will collaborate with for today’s recitation.  Choose someone with."

Similar presentations


Ads by Google