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.

Slides:



Advertisements
Similar presentations
Graphics Graphics Java Vectors Java Enumeration Graphical Spreadsheets
Advertisements

Graphics You draw on a Graphics object The Graphics object cannot directly be created by your code, instead one is generated when the method paintComponent.
Graphics Chapter 16.  If you want to draw shapes such as a bar chart, a clock, or a stop sign, how do you do it?
MiniDraw Testing COMP 102 # T1
LAB SESSION 7 Graphical user interface Applet fundamentals Methods in applets Execution of an applet Graphics class.
Inheritance // A simple class hierarchy. // A class for two-dimensional objects. class TwoDShape { double width; double height; void showDim() { System.out.println("Width.
INTERFACES IN JAVA 1.Java Does not support Multiple Inheritance directly. Multiple inheritance can be achieved in java by the use of interfaces. 2.We need.
Recitation 11 November 11, Today’s Goals:  Automatic refresh  Learn and apply the Observer pattern.
Faculty of Sciences and Social Sciences HOPE Structured Problem Solving Object Oriented Concepts 2 Stewart Blakeway FML 213
Object-Oriented Programming (OOP) Lecture No. 6
1 Lecture 06(Abstract Classes)Lecture 9 Abstract Classes Overview  Abstract Classes: A Definition.  Declaring Abstract Classes.  Abstract Methods: A.
COMP 110 Introduction to Programming Mr. Joshua Stough October 8, 2007.
Chapter 2 storing numbers and creating objects Pages in Horstmann.
7-2 Similarity and transformations
GEOMETRY Today we are going to learn about some geometric shapes...
Kindergarten Math Janelle Ward. Lesson Objectives Students will be able to identify and describe shapes 100% of the time. Students will be able to identify.
HOW MANY SHAPES do you see?
Chapter 6 Class Inheritance F Superclasses and Subclasses F Keywords: super F Overriding methods F The Object Class F Modifiers: protected, final and abstract.
Chapter 3.5 Logic Circuits. How does Boolean algebra relate to computer circuits? Data is stored and manipulated in a computer as a binary number. Individual.
C OMP 401 P ATTERNS, I NTERFACES AND O BJECT E DITOR Instructor: Prasun Dewan.
HTML presentation Embedding Graphics in Web Pages n HTML uses an empty tag called the (image tag) n n n or n n n Note: all web production tools do insert.
Week 3 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Appendices A - F A-F Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
C OMP 110/401 C OMPOSITE A NNOTATIONS Instructor: Prasun Dewan.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
CSC 205 Java Programming II Polymorphism. Topics Polymorphism The principle of substitution Dynamic binding Object type casting Abstract class The canonical.
Lecture 8.3 The Use of JComponent. © 2006 Pearson Addison-Wesley. All rights reserved More About the Standard Drawing Classes java.awt.Container.
1.8: Perimeter, Circumference, and Area
The Coordinate Plane Section 1.6. Goal - After today, you will be able to:  Find the distance between any two points in the coordinate plane.  Find.
CS177 RECITATION WEEK 7 Input and Output (Text & Graphical)
Lecture 1: UML Class Diagram September 12, UML Class Diagrams2 What is a Class Diagram? A class diagram describes the types of objects in the system.
Java Graphics Graphical Components as objects. Graphics A Component is ◦A rectangular region of a computer screen ◦A graphical entity ◦Can sometimes contains.
(C) 2010 Pearson Education, Inc. All rights reserved.  Class Graphics (from package java.awt) provides various methods for drawing text and shapes onto.
Graphics Concepts CS 2302, Fall /17/20142 Drawing in Android.
Inheritance CSI 1101 Nour El Kadri. OOP  We have seen that object-oriented programming (OOP) helps organizing and maintaining large software systems.
Math I, Sections 2.1 – 2.4 Standard: MM1A2c Add, subtract, multiply and divide polynomials. Today’s Question: What are polynomials, and how do we add,
C OMP 401 G RAPH VS. D AG VS. T REE O BJECT S TRUCTURES Instructor: Prasun Dewan.
Lecture 3.1 Using Graphics with JFrame. © 2006 Pearson Addison-Wesley. All rights reserved javax.swing.JFrame - int x - int y - int width - int.
Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan.
Please open JCreator and follow these steps: 1)Configure  Options 2)JDK Tools 3)Choose Run Applet from drop-down 4)Click Default, then Edit 5)Click the.
VG101 RECITATION 5 By TAs. CONTENTS How to read Vg101Class.h Samples about graphics About assignment 5 Array.
How many …?. What shape can you see? I can see some _____. Q1 Q1 stars.
1 Sections 5.1 – 5.2 Digital Image Processing Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
CompSci 4 Java 4 Apr 14, 2009 Prof. Susan Rodger.
Rotation Translation Reflection. Review of Cartesian Plane.
By Ashby Morell Clip Art from Microsoft Office 2007
Area Approximation This template can be used as a starter file for presenting training materials in a group setting. Sections Right-click on a slide to.
Unit 1: Transformations Lesson 3: Rotations
Recitation #3 Comp Semion Piskarev.
Inheritance "Question: What is the object oriented way of getting rich? Answer: Inheritance.“ “Inheritance is new code that reuses old code. Polymorphism.
Get out your classwork from yesterday so we can go over #25!
What shape am I? I am a plane shape. I have 4 sides.
Week 6 Object-Oriented Programming (2): Polymorphism
Beans and object editor
Composite Objects with Object Editor With slides from Andrew Ghobrial
Recitation 2 September 2, 2011 Ben Newton.
Recitation 4 September 16, 2011.
Comp 401 Concluding Remarks
Class Hierarchies and Type Conformance
Recitation 7 October 7, 2011.
Shapes.
Recitation 10 November 3, 2011.
Recitation 6 September 30, 2011.
Recitation 12 November 18, 2011.
Recitation 9 October 28, 2011.
Recitation 3 September 9, 2011 Wade Gobel.
Cross section: Triangle
Recitation 5 In this recitation you will have an example on displaying multiple objects on ObjectEditor. The code can be found in the recitation page.
Knowledge Byte In this section, you will learn about:
Introduction to Computer Science and Object-Oriented Programming
Presentation transcript:

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 whom you have NOT collaborated during a previous recitation.

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

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

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.

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(); }

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(); }

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); }

Recitation Specification  Download Recitation5.zip from the Recitations page:  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()

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: