Exam 2 Review. variable types boolean - true or false String - "hello" int - 14 double - 3.14159.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

Chapter 3 DATA: TYPES, CLASSES, AND OBJECTS. Chapter 3 Data Abstraction Abstract data types allow you to work with data without concern for how the data.
Computer Programming Lab 8.
Animation Mrs. C. Furman. Animation  We can animate our crab by switching the image between two pictures.  crab.png and crab2.png.
Chapter 2 - The First Program: Little Crab
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Fundamentals of Strings and Characters Characters.
1 Objects and Classes Introduction to Classes Object Variables and Object References Instantiating Objects Using Methods in Objects Reading for this Lecture:
Class template Describing a generic class Instantiating classes that are type- specific version of this generic class Also are called parameterized types.
Understanding class definitions Looking inside classes.
Summary of last week / Lab6A int x = 14; GreenfootImage myImage = new GreenfootImage(); this.setImage( myImage ); this.setLocation( 100, 100 ); myImage.setColor(
CSC 142 C 1 CSC 142 Object based programming in Java [Reading: chapter 4]
CSE 113 Introduction to Computer Programming Lecture slides for Week 4 Monday, September 19 th, 2011 Instructor: Scott Settembre.
BPJ444: Business Programming Using Java Classes and Objects Tim McKenna
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
CS 106 Introduction to Computer Science I 03 / 19 / 2007 Instructor: Michael Eckmann.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
Lecture # 8 Constructors Overloading. Topics We will discuss the following main topics: – Static Class Members – Overloaded Methods – Overloaded Constructors.
CSE 113 Introduction to Computer Programming Lecture slides for Week 5 Monday, September 26 th, 2011 Instructor: Scott Settembre.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
© A+ Computer Science - public Triangle() { setSides(0,0,0); } Constructors are similar to methods. Constructors set the properties.
Agenda Object Oriented Programming Reading: Chapter 14.
ECE122 Feb. 22, Any question on Vehicle sample code?
QuadraticEquation class. Background A quadratic equation is a second-order polynomial equation in a single variable x, ax 2 + bx + c = 0 (with a≠0.)
1 Programming Week 2 2 Inheritance Basic Java Language Section.
Chapter 10 Defining Classes. The Internal Structure of Classes and Objects Object – collection of data and operations, in which the data can be accessed.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Functions Overview Functions are sequence of statements with its own local variables supports modularity, reduces code duplication Data transfer between.
Static. 2 Objectives Introduce static keyword –examine syntax –describe common uses.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Topic 8Classes, Objects and Methods 1 Topic 8 l Class and Method Definitions l Information Hiding and Encapsulation l Objects and Reference Classes, Objects,
A: A: double “4” A: “34” 4.
Objects and Classes Start on Slide 30 for day 2 Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Much of.
Object Oriented Programming and Data Abstraction Rowan University Earl Huff.
CS 116 Lecture 1 John Korah Contains content provided by George Koutsogiannakis & Matt Bauer.
Powerpoint slides from A+ Computer Science Modified by Mr. Smith for his course.
AP Java Ch. 4 Review Question 1  Java methods can return only primitive types (int, double, boolean, etc).
Lecture 10: Object Oriented Programming Tami Meredith.
Lecture 3: More on Classes Textbook: Chapter 2 Recap: –Classes vs. Objects –Q: What comes first a class or an object? –Q: Do we need a class to create.
Session 7 More Implications of Inheritance & Chapter 5: Ball World Example.
CS180 Recitation Chapter 7: Defining Your Own Classes II.
Powerpoint slides from A+ Computer Science Modified by Mr. Smith for his course.
Review – Primitive Data What is primitive data? What are 3 examples of primitive data types? How is a piece of primitive data different from an object?
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
Chapter 4 - Finishing the Crab Game
Input, Output and Variables GCSE Computer Science – Python.
Chapter 4 - Finishing the Crab Game
Chapter 5 – Making Music: An On-Screen Piano (Part 1 – Using Loops)
Examples of Classes & Objects
A basic tutorial for fundamental concepts
Chapter 3 – Improving the Crab Game
Software Development Java Classes and Methods
Agenda Warmup Finish 2.4 Assignments
Intro To Classes Review
CS 302 Week 11 Jim Williams, PhD.
The Little Crab Scenario
Review Operation Bingo
Classes & Objects: Examples
Inheritance.
Defining Class Member Data/characteristics
Week 4 Object-based Programming (2) Classes and Objects: A Deeper Look
© A+ Computer Science - OOP © A+ Computer Science -
CS139 October 11, 2004.
Which best describes the relationship between classes and objects?
Object based programming in Java
Methods, Data and Data Types
Relational Operators.
Object based programming in Java
Chapter 4 Constructors Section 4.4
COMPUTING.
Day 11 The Last Week!.
Presentation transcript:

Exam 2 Review

variable types boolean - true or false String - "hello" int - 14 double

instantiation crate a copy of a class for use by another class Utilities screen1 = new Utilities(); must use "new" can then use to call methods: screen1.writeToScreen( "hello", 10, 20 );

constructor see page 44 a method that has the same name as the class runs on instantiation of that class see ScreenWorld class

screen coordinates what do x and y mean where is (0,0) where is (0, 600) where is (600, 0) where is (600, 600) setLocation( x, y) method

GreenfootImage instantiate an object of the GreenfootImage class GreenfootImage myImage = new GreenfootImage( ); this.setImage( myImage ); in an Actor class myImage.drawString(....

Lab review the main point of each lab Lab 6 - screen writing Lab 5 - GreenfootImage, VirusPatrol, Virus Lab 4 - moving an Image, Hero( )

class / method/ variable definitions method definitions - public void act( ) class definitions - public class Hero extends Actor instance variable definitions - int x = 0; object definition (instantiation) - classname objectname = new classname( );

converting String s = "hello"; int i = 0; double x = ; ints to doubles x = (double) i ; doubles to ints i = (int) x; numbers to Strings s = String.valueOf( i ); s = String.valueOf( x );

writing to screen GreenfootImage myImage = new GreenfootImage( ); this.setImage( myImage ); myImage.setColor( Color.RED ); myImage.drawString("hello", 10, 10);

code int Looper = 0; while (Looper <= 100) { Looper++; // same as Looper = Looper+1; }

code if (x < 20 ) { y = 0; } else // i.e. if x >= 20 ! { y= 1; }

libraries greenfoot.*; GreenfootImage java.awt.*;Colors java.lang.Math;Math functions

methods with the same name? e.g. writeToScreen( String s, int x, int y ) writeToScreen( int i, int x, int y ) writeToScreen( double f, int x, int y ) writeToScreen( boolean t, int x, int y ) called OVERLOADING parameter list must be different

operators = assignment comparisons: = = equals ! = not equals (haven't used this yet) <less than <=less than or equal >greater than >=greater than or equal

operators && AND ||OR if ( (x = 10 )) if (( x==0 ) && ( y == 0))

if... else if ( x == 10 ) { // do this } else { // do THIS when x is not equal to 10 }

not on the test individual MATH functions plotting a curve