ClassesAndObjects2

ClassesAndObjects2 - CIS3023: Programming Fundamentals for...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Ganesh Viswanathan Classes and Objects (contd.) Course Lecture Slides 19 May 2010
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Classes and Objects Credits: Adapted from CIS-3023 lecture slides (Spring 2010) by Dr Seema Bandyopadhyay , University of Florida, Gainesville. 2
Background image of page 2
Object Instantiation Declaring and Creating object in two steps Declaring and Creating object in single step 3 // <ClassName> <objectRefVar>; Circle myCircle; myCircle = new Circle(); // <ClassName> <objectRefVar> = new <ClassName>(); Circle myCircle = new Circle();
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Trace Code 4 Circle myCircle = new Circle(5.0); Circle yourCircle = new Circle(); yourCircle.radius = 100; Declare myCircle no value myCircle animation
Background image of page 4
Trace Code, cont. : Circle radius: 5.0 5 Circle yourCircle = new Circle(); yourCircle.radius = 100; no value myCircle Create a circle animation
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Trace Code, cont. : Circle radius: 5.0 6 Circle myCircle = new Circle(5.0); Circle yourCircle = new Circle(); yourCircle.radius = 100; reference value myCircle Assign object reference to myCircle animation
Background image of page 6
Trace Code, cont. : Circle radius: 5.0 7 Circle myCircle = new Circle(5.0); Circle yourCircle = new Circle(); yourCircle.radius = 100; reference value myCircle no value yourCircle Declare yourCircle animation
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Trace Code, cont. : Circle radius: 5.0 8 Circle myCircle = new Circle(5.0); yourCircle.radius = 100; reference value myCircle no value yourCircle : Circle radius: 1.0 Create a new Circle object animation
Background image of page 8
Trace Code, cont. : Circle radius: 5.0 9 Circle myCircle = new Circle(5.0); Circle yourCircle = new Circle( ); yourCircle.radius = 100; reference value myCircle reference value yourCircle : Circle radius: 1.0 Assign object reference to yourCircle animation
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Accessing Objects Referencing the object’s data: Invoking the object’s method: 10 // objectRefVar.data myCircle.radius //objectRefVar.methodName(arguments) myCircle.getArea()
Background image of page 10
Trace Code, cont.
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 34

ClassesAndObjects2 - CIS3023: Programming Fundamentals for...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online