Defining Class Member Data/characteristics

Slides:



Advertisements
Similar presentations
Operator overloading redefine the operations of operators
Advertisements

For(int i = 1; i
void count_down (int count) { for(i=count; i>1; i--) printf(" %d\t", count); } printf("A%d\n", count); if(count>1) count_down(count-1); printf("B%d\n",
Contents o Introduction o Characteristics of Constructor. o Types of constructor. - Default Constructor - Parameterized Constructor - Copy Constructor.
Introduction to Programming Lecture 39. Copy Constructor.
Chapter 8. Operator Overloading Operator overloading gives the opportunity to redefine C++ Operator overloading refers to redefine C++ operators such.
EC-241 Object-Oriented Programming
C++ Classes & Data Abstraction
Getting your Feet Green
Translate, Rotate, Matrix Pages Function Function Definition Calling a function Parameters Return type and return statement.
Chapter 8 - Creating Images and Sound Bruce Chittenden.
Games and Simulations O-O Programming in Java The Walker School
Animation Mrs. C. Furman. Animation  We can animate our crab by switching the image between two pictures.  crab.png and crab2.png.
of Kent A practical introduction to Greenfoot David Barnes Lecturer in Computer Science University of.
Chapter 2 - The First Program: Little Crab
Program: Little Crab Mr Gano.
Wombats Creating Games with Greenfoot The Walker School – Games and Simulations
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 8.1 – 8.5.
UML Class Diagram: class Rectangle
Test review. When? Monday 9/27 in class Know Greenfoot How many classes? Top-most classes? What does each button do? Lowest child class?
Exam 2 Review. variable types boolean - true or false String - "hello" int - 14 double
Summary of last week / Lab6A int x = 14; GreenfootImage myImage = new GreenfootImage(); this.setImage( myImage ); this.setLocation( 100, 100 ); myImage.setColor(
Chapter 5 - Making Music: An On-Screen Piano
CSE 113 Introduction to Computer Programming Lecture slides for Week 4 Monday, September 19 th, 2011 Instructor: Scott Settembre.
Greenfoot. Getting Started Open the Greenfoot download site: Select Greenfoot
Static Keyword. What is static The static keyword is used when a member variable of a class has to be shared between all the instances of the class. All.
Chapter 8 – Mouse Input, Images and Sound. Chapter 8 - Content In contrast to previous chapters, we will not build a complete scenario in this chapter.
CSE 113 Introduction to Computer Programming Lecture slides for Week 12 Monday, November 14 th, 2011 Instructor: Scott Settembre.
Lecture 4. Greenfoot 1 Pablo Romero, Department of Informatics Greenfoot Programming simulations and games in Java.
Picture It Game with GUI Control Class Pepper. Class Diagram Game (controller & maybe model) – holds the state of the game – has a static main method.
PImage. Let’s look at the PImage class in ProcessingPImage –What are the fields (i.e., variables)? –What methods are available? –What about the constructor---how.
Greenfoot Game Programming Club.
Lesson 3: Arrays and Loops. Arrays Arrays are like collections of variables Picture mailboxes all lined up in a row, or storage holes in a shelf – You.
Repetition Control Structure. Introduction Many applications require certain operations to be carried out more than once. Such situations require repetition.
Introduction To Greenfoot
CS 5JA Introduction to Java Pop Quiz Define/Explain encapsulation. In object-oriented programming, encapsulation refers to the grouping of data and the.
Chapter 2 – The Little Crab Program:. Little Crab Scenario Inheritance: The Arrows Denote Hierarchy Crab is an Animal Animal is an Actor Therefore, It.
Inheritance in C++ Bryce Boe 2012/08/28 CS32, Summer 2012 B.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
Creating Scenarios In Greenfoot. Greenfoot Scenarios are made up of: Greenfoot Scenarios are made up of: A World class. A World class. Actor classes.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Image from
Staples are our staple Building upon our solution.
Selection Statement Chapter 3. A Java Language Program Is a Class A Class has data declarations and methods A Method has statements or instructions to.
Chapter 4 - Finishing the Crab Game
Let’s COUNT In tenths
Chapter 4 - Finishing the Crab Game
Chapter 5 – Making Music: An On-Screen Piano (Part 1 – Using Loops)
Chapter 3 – Improving the Crab Game
Structs versus Classes
Fundamental of Java Programming
UML Class Diagram: class Rectangle
Introduction to Object-oriented Program Design
The Little Crab Scenario
An Introduction to Java – Part II
Organizing Memory in Java
10:00.
Problem Solving with Data Structures using Java: A Multimedia Approach
Implementing Classes Chapter 3.
Java Programming with Multiple Classes
Evaluate the limit: {image} Choose the correct answer from the following:
Adding Behaviors (methods)
Methods, Data and Data Types
Greenfoot November 8, 2009.
An Example of Inheritance
Lecture 8 Inheritance CS140 Dick Steflik.
Lab – 2018/04/12 implement getTotalCount to return how many ‘nMatrix’s are allocated(exist) (modify constructor and destructor, use static variable and.
Put the on A on the keyboard.
Constructors and Deconstructor
Chapter 11 Classes.
Presentation transcript:

Defining Class Member Data/characteristics B. Ramamurthy

Lets Review the “Class” Concept Class Name Class data/characteristics Class behavior/methods Lets define our own Crab and Lobster class

Lets work with Greenfoot Controlling actors from keyboard; counting; variables; World with pre-populated actors

Crab Class Crab Crab(); // constructor void lookForWorm(); void checkKeyPress() void switchImage() Void eatWorm() //data int numberOfWorms; GreenfootImage image1; GreenfootImage image2; //from its superclass or ancestor int x; int y;