cs260 object oriented programming
play

CS260: Object Oriented Programming Review - February 9, 2016 - PowerPoint PPT Presentation

CS260: Object Oriented Programming Review - February 9, 2016 Test next time Objects & Classes Overview Inheritance UML Basic Programming Stuff... Objects And Classes What is an Object? What are


  1. CS260: Object Oriented Programming Review - February 9, 2016

  2. ● Test next time… Objects & Classes ○ Overview Inheritance ○ ○ UML ○ Basic Programming Stuff...

  3. Objects And Classes What is an Object? ● ● What are the two parts of an Object? ● What is a Class? What is a field? ● What is a Method? ● ● What is a Constructor?

  4. Class Definition Classes ● a. What does a class definition look like? public class ClassNameHere { //this is where fields go ClassNameHere(){ //this is where we set up the class } //this is where methods go }

  5. Class Definition Classes - Given a Class Definition ● a. What fields are in this Class? b. What methods are in this Class? c. Label the section representing the Class State d. Label the section representing the Class Behaviors e. What parameters does the Constructor take?

  6. OOP - Inheritance ● What is inheritance? What does inheritance look like in UML? ● What does inheritance look like in code? ● ○ Standard Class declaration but with “extends” keyword public class ChildClass extends ParentClass { //this is where fields go ChildClass(){ //this is where we set up the class } //this is where methods go }

  7. Translate into UML public class Bubble { int x, y; int radius; int col; Bubble(int startX, int startY, int rad, int c){ x = startX; y = startY; radius = rad; col = c; } public void floatUp(){ if(y < 0){ y = height; } y--; } public void drawBubble(){ noFill(); stroke(col); ellipse(x, y, radius, radius); } }

  8. Translate into UML From Text Description ● ○ Cartoon Characters There is a Bird Class ■ ■ The Bird Class has a Beak Class Tweety Bird inherits from the Bird Class ■ ■ A Duck Class inherits from the Bird Class ■ Daffy Duck and Donald Duck, and Scrooge McDuck Classes all inherit from the Duck Class

  9. UML Class Diagrams Label ● ○ Class Name State ○ ○ Behavior Fields ○ ○ Methods Relationships ● ○ X Inherits from Y (is a) ○ A Belongs to B (B has a A)

  10. Basic Programming Stuff... PascalCase vs camelCase ● ● Constants ● Data types Loops ● Indentation ● ● Switch-Case ● Arrays Functions ● Scope ●

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend