Lab 7: Tree & Forest. Drawing a Forest Created by Emily Hill & Jerry Alan Fails.

Slides:



Advertisements
Similar presentations
2D Graphics Drawing Things. Graphics In your GUI, you might want to draw graphics E.g. draw lines, circles, shapes, draw strings etc The Graphics class.
Advertisements

The Point Class public class Point { public double x; public double y; public Point(double x0, double y0) { x = x0; y = y0; } public double distance(Point.
Laboratory Study II October, Java Programming Assignment  Write a program to calculate and output the distance traveled by a car on a tank of.
Lab 10: Bank Account II Transaction List, error checking & aggregation.
Visual C++ Programming: Concepts and Projects Chapter 13A: Object-Oriented Programming (Concepts)
ITEC200 – Week03 Inheritance and Class Hierarchies.
COMS S1007 Object-Oriented Programming and Design in Java July 8, 2008.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Chapter 41 Defining Classes and Methods Chapter 4.
Fall 2007CS 2251 Inheritance and Class Hierarchies Chapter 3.
Chapter Day 5. © 2007 Pearson Addison-Wesley. All rights reserved2-2 Agenda Day 5 Questions from last Class?? Problem set 1 Posted  Introduction on developing.
Inheritance (notes for 10/26 lecture). Inheritance Inheritance is the last of the relationships we will study this semester. Inheritance is (syntactically)
Aalborg Media Lab 21-Jun-15 Software Design Lecture 2 “ Data and Expressions”
CSC 160 Computer Programming for Non-Majors Lecture #3c: Working with Pictures (continued) Prof. Adam M. Wittenstein
ObjectDraw and Objects Early Chris Nevison Barbara Wells.
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
Chapter 2 storing numbers and creating objects Pages in Horstmann.
COMS S1007 Object-Oriented Programming and Design in Java August 7, 2007.
COMS S1007 Object-Oriented Programming and Design in Java July 3, 2007.
Chapter Day 9. © 2007 Pearson Addison-Wesley. All rights reserved4-2 Agenda Day 8 Questions from last Class?? Problem set 2 posted  10 programs from.
CS 106 Introduction to Computer Science I 03 / 17 / 2008 Instructor: Michael Eckmann.
Chapter 5- Even more about objects and methods. Overview n Designing methods n Methods, methods, methods n Overloading methods n Constructor methods n.
Computer Science II 810:062 Section 01 Session 2 - Objects and Responsibilities.
Writing Classes (Chapter 4)
Lab 5: drawing and output User Interface Lab: GUI Lab Sep. 25 th, 2013.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Summary and Exam COMP 102.
Agenda For Feb Finish up Unit 3 Exercises on page Unit 4 Exercises on page 33. Question #2 3. Create a Happy Face Java Applet (due next class).
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
Introduction to Programming with Java. Overview What are the tools we are using – What is Java? This is the language that you use to write your program.
Object Oriented Design: Identifying Objects
Lab 6: Shapes & Picture Extended Ellipse & Rectangle Classes Stand-Alone GUI Applications.
Chapter 8. About the Midterm Exam.. Exam on March 12 Monday (Tentatively) Review on March 7 Wednesday Cover from Chapter 6 Grades will be out before spring.
Lecture :2 1.  DEFENTION : Java is a programming language expressly designed for use in the distributed environment of the Internet. It was designed.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
CS 112 Department of Computer Science George Mason University CS 112 Department of Computer Science George Mason University Final Review Lecture 14.
More on Hierarchies 1. When an object of a subclass is instantiated, is memory allocated for only the data members of the subclass or also for the members.
Program that runs in appletviewer (test utility for applets) Web browser (IE, Communicator) Executes when HTML (Hypertext Markup Language) document containing.
CSC1401 Classes - 1. Learning Goals Computing concepts Identifying objects and classes Declaring a class Declaring fields Default field values.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
CSC1401 Classes - 2. Learning Goals Computing concepts Adding a method To show the pictures in the slide show Creating accessors and modifiers That protect.
1 Principles of Computer Science I Prof. Nadeem Abdul Hamid CSC 120 – Fall 2005 Lecture Unit 2 - Using Objects.
Programming in Java (COP 2250) Lecture 8 Chengyong Yang Fall, 2005.
Drawing rectangles and ovals in the Applet window Displaying Text in the Java Console Window Demo of the HelloAgain program Arithmetic expressions Examples.
CS0007: Introduction to Computer Programming Classes: Documentation, Method Overloading, Scope, Packages, and “Finding the Classes”
Graphics Concepts CS 2302, Fall /17/20142 Drawing in Android.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Lab 7: BoxCar Class. Drawing a BoxCar Step 1:Create classes for Circle & Rectangle (done!) Step 2:Create a BoxCarPart class that can draw this part at.
Chapter 5 Introduction To Form Builder. Lesson A Objectives  Display Forms Builder forms in a Web browser  Use a data block form to view, insert, update,
Introductory Graphics Chapter Three. Computer Graphics §Full motion pictures (“Star Wars”) l animated films §Virtual reality §Games §Simulators (air craft.
JAVA INTRODUCTION. What is Java? 1. Java is a Pure Object – Oriented language 2. Java is developing by existing languages like C and C++. How Java Differs.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
SourceAnatomy1 Java Source Anatomy Barb Ericson Georgia Institute of Technology July 2008.
CSCI 51 Introduction to Programming Dr. Joshua Stough February 24, 2009.
CS 112 Introduction to Programming Java Graphics Yang (Richard) Yang Computer Science Department Yale University 208A Watson, Phone:
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 - Introduction to Java Applets Will not cover Section 3.7 Thinking About Objects: Identifying.
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.
© 2004 Pearson Addison-Wesley. All rights reserved3-1 Objects Declaration: String title;  title (object variable) of type String( Class )  title is just.
HW: Finish Problem 4.3 (assigned parts) Weekly Review due Friday Do Now3/7/16 Using graph paper, draw a possible net for a rectangular prism with a length.
Chapter 02 Data and Expressions.
Chapter 3 Syntax, Errors, and Debugging
Haidong Xue Summer 2011, at GSU
Chapter 3: Using Methods, Classes, and Objects
Inheritance "Question: What is the object oriented way of getting rich? Answer: Inheritance.“ “Inheritance is new code that reuses old code. Polymorphism.
Objects First with Java
Objects First with Java Transaction List, error checking & aggregation
Building Java Programs
Chapter 4: Writing classes
Outline Character Strings Variables and Assignment
Presentation transcript:

Lab 7: Tree & Forest

Drawing a Forest Created by Emily Hill & Jerry Alan Fails

Drawing a Forest Step 1:Create classes for Rectangle & Triangle (done) Step 2:Create a Tree class that can draw a tree at any: x, y position; width, height; color Step 3:Create a Forest class with at least 3 Trees Created by Emily Hill & Jerry Alan Fails

Step 2: Tree class Create a new Tree class Has 2 fields: a triangle for the top & a rectangle for the trunk Has 3 constructors: –Default –One with 4 parameters: x, y, width, & height –One with 6 parameters: x, y, width, height, topColor, trunkColor Getters/setters for topColor, trunkColor Has a public setBounds method that takes: x, y, width, height –(Might want to add this method to Triangle and Rectangle, but you don’t need to as you can use setX, setY, setWidth, and setHeight) –Tree should start at x, y and extend to width & height –Top and trunk should be relative to one another and to size of tree: Trunk 1/4 height of tree, 1/5 width Top 3/4 height of tree, full width Has a paintComponent method that has a Graphics parameter and calls the corresponding paintComponent methods for the 2 fields Test: add Tree(s) to Picture class, use different constructors, change the size of the Tree in the constructor or init method and test that it works Created by Emily Hill & Jerry Alan Fails

Step 3: Forest class Create a new Forest class Has at least 3 Tree fields Has a constructor that takes 4 parameters: x, y, width, height Has a draw method that has a Graphics parameter and calls the corresponding draw methods for the 3 fields Test: replace Tree field in Picture with a Forest Modify position/sizes in PictureApplet.init() or the Picture constructor Look at how easy it is to aggregate components! Created by Emily Hill & Jerry Alan Fails

Homework Finish lab exercise (due after exam) Created by Emily Hill & Jerry Alan Fails

General Review Lecture notes Class exercises Labs CodingBat Chapters 1-4 –Where Chapter 1 Chapter 2 Chapter 3 (except , ) Chapter 4 (except ) –What: Key concepts Concept summary Section headings For extra help look at the exercises

Chapter 1: Computer Basics Computer processing Hardware components Networks The Java programming language Program development Object-oriented programming

Chapter 2: Data & Expressions Character strings Variables and assignment Primitive data types Expressions Data conversions Interactive programs – the Scanner class Graphics, Applets, drawing shapes

Chapter 3: Using Classes and Objects Creating objects The String class Packages – import, Java API Classes: Random, Math

Chapter 4: Writing Classes Classes and objects Anatomy of a class –Three main components of a class –What each item does –How to write it in code Encapsulation