Jan212010

Jan212010 - UC Santa Cruz Computer Science Game Design CMPS...

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

View Full Document Right Arrow Icon
Computer Science – Game Design UC Santa Cruz Click to edit Master subtitle style 11/10/10 CMPS 20: Game Design Experience Inheritance Polymorphism Collision Detection
Background image of page 1

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

View Full DocumentRight Arrow Icon
Computer Science – Game Design UC Santa Cruz 11/10/10 Classification Classification is the act of assigning things to categories of things. The is-a relationship Examples: A Volkwagen Jetta is a (kind of) car. A hot dog is a (kind of) food. Classification is at the heart of
Background image of page 2
Computer Science – Game Design UC Santa Cruz 11/10/10 Developing classes The process of taking a set of real world objects and developing its associated category is called abstraction . Example: If I give you the set of food items: Cheese whizz, hot dog, corn chips, bran flakes, chicken
Background image of page 3

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

View Full DocumentRight Arrow Icon
Computer Science – Game Design UC Santa Cruz 11/10/10 Hierarchies of Categories Sometimes there are situations where you have multiple levels of categories Category1 is a (kind of) Category2 is a (kind of) Category3 Example A cell phone is a (kind of) telephone A wired phone is a (kind of) telephone An iPhone is a (kind of) cell phone Telephone is an abstract category In software, may want to represent things like telephone , but never have direct instances Only want instances of sub-categories
Background image of page 4
Computer Science – Game Design UC Santa Cruz 11/10/10 Representing Abstract Two ways to represent abstract categories Interface Class properties Method names and parameter lists, but no method implementations of any methods. Abstract Class Class variables
Background image of page 5

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

View Full DocumentRight Arrow Icon
Computer Science – Game Design UC Santa Cruz 11/10/10 Interface Describes a set of methods, properties that must be implemented by all subclasses But, no implementation details are given Subclasses can implement the methods and properties as they see fit So long as they match the types of the properties, method return values, and method parameters
Background image of page 6
Computer Science – Game Design UC Santa Cruz 11/10/10 Defining an interface Naming convention: Put capital “I” in front of interface name [attributes] [access-modifiers] interface identifier [:base- interface(s)] { interface-body } Simple example: interface ITelephone { public string PhoneNum {get; set;} // Phone number property, can read and write void display_phone_num(); // Output phone number }
Background image of page 7

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

View Full DocumentRight Arrow Icon
Computer Science – Game Design UC Santa Cruz 11/10/10 Using an Interface Syntactically, looks like inheritance Must implement all aspects of interface ITelephone { public string PhoneNum {get; set;} // Phone number property, can read and write void display_phone_num(); // Output phone number } public cellphone : ITelephone { public string PhoneNum {get; set;} // Use automatic property to implement interface property public void display_phone_num() { System.Console.WriteLine(“cell phone number is {0}”, PhoneNum); } }
Background image of page 8
UC Santa Cruz 11/10/10 Abstract Classes
Background image of page 9

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

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

Page1 / 33

Jan212010 - UC Santa Cruz Computer Science Game Design CMPS...

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

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