In Class Practice 2 - COP 3330 Object-Oriented Programming...

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

View Full Document Right Arrow Icon
COP 3330: In Class Practice #2 Page 1 © Dr. Mark Llewellyn COP 3330: Object-Oriented Programming Summer 2011 In Class Practice #2 Department of Electrical Engineering and Computer Science Computer Science Division University of Central Florida Instructor : Dr. Mark Llewellyn [email protected] HEC 236, 407-823-2790 http://www.cs.ucf.edu/courses/cop3330/sum2011
Background image of page 1

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

View Full DocumentRight Arrow Icon
COP 3330: In Class Practice #2 Page 2 © Dr. Mark Llewellyn In Class Practice #2 Let’s convert the UML class diagram shown below into an implemented Java class and use that class to illustrate the differences between class variables/methods and instance variables/methods. Thing a: int = 5 – b: int + Thing() + getA (): int + setA (int aValue):void + getB (): int Underlining a variable or a method in a UML diagram indicates that the variable or method is a class method. This is also the standard format for specifying a default value for a variable in UML.
Background image of page 2
COP 3330: In Class Practice #2 Page 3 © Dr. Mark Llewellyn Static modifier indicates a class variable. Create the class and add the class characteristics and constructors Every object created using the default constructor will have a b value of 1. Every object created using the int-specific constructor will have a b value equal to the value passes as a parameter.
Background image of page 3

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

View Full DocumentRight Arrow Icon
COP 3330: In Class Practice #2 Page 4 © Dr. Mark Llewellyn Add the remaining methods The methods getA() and setA() are class methods. Referencing a class variable or method must be done in a static manner. This means that it is not referenced via an object but via the class directly.
Background image of page 4
COP 3330: In Class Practice #2 Page 5 © Dr. Mark Llewellyn Construct the main method
Background image of page 5

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

View Full DocumentRight Arrow Icon
COP 3330: In Class Practice #2 Page 6 © Dr. Mark Llewellyn Execute the program
Background image of page 6
COP 3330: In Class Practice #2 Page 7 © Dr. Mark Llewellyn Why the output looks like it does. . .
Background image of page 7

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

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

Page1 / 32

In Class Practice 2 - COP 3330 Object-Oriented Programming...

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

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