1 / 30

COP 3503 FALL 2012 Shayan Javed Lecture 10

COP 3503 FALL 2012 Shayan Javed Lecture 10. Programming Fundamentals using Java. In-Class Exercise. Extra Credit. 2% extra credit. Angry Birds. How many of you have played it?. Angry Birds. Well-designed, simple game. Angry Birds. Well-designed, simple game Throw birds at pigs .

lael
Download Presentation

COP 3503 FALL 2012 Shayan Javed Lecture 10

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COP 3503 FALL 2012ShayanJavedLecture 10 Programming Fundamentals using Java

  2. In-Class Exercise

  3. Extra Credit • 2% extra credit

  4. Angry Birds How many of you have played it?

  5. Angry Birds • Well-designed, simple game

  6. Angry Birds • Well-designed, simple game • Throw birds at pigs

  7. Angry Birds • Well-designed, simple game • Throw birds at pigs • Physics!

  8. Angry Birds • Well-designed, simple game • Throw birds at pigs • Physics! • Made millions

  9. Angry Birds • Well-designed, simple game • Throw birds at pigs • Physics! • Made millions • Available on pretty much every platform

  10. Angry Birds • Well-designed, simple game • Throw birds at pigs • Physics! • Made millions • Available on pretty much every platform • Even Google Chrome!

  11. Angry Birds • Exercise: • Design the class structure for the game (UML diagram)

  12. Angry Birds • Exercise: • Design the class structure for the game (UML diagram) • Try to use everything we have learned so far: • Classes/Inheritance/Abstract Classes • Interfaces • Interaction between classes

  13. Angry Birds • Quick look at some of the “objects” in the game: • Different types of birds: • Red (Regular) • Blue (explodes into 3 smaller ones) • Yellow (accelerates mid-air) • Black (explodes) • 3 more but we can skip those...

  14. Angry Birds • Different types of pigs:

  15. Angry Birds • Different barriers

  16. Angry Birds • Possible solution: • Start off with a class which forms the basis of every object in the world

  17. Angry Birds abstract class Sprite implementsCloneable { Point position; ImagebitmapFile; // JPEG, PNG, etc... doublesizeX; doublesizeY; public Object clone() {} // clone method }

  18. Angry Birds abstract class Bird extendsSpriteimplementsCloneable { double strength; public Object clone() {} // clone method }

  19. Angry Birds abstract class Bird extendsSpriteimplementsCloneable { double strength; public Object clone() {} // clone method } class RedBirdextendsBirdimplementsCloneable { // inherits properties from superclass public Object clone() {} // clone method }

  20. Angry Birds abstract class Bird extendsSpriteimplementsCloneable { double strength; public Object clone() {} // clone method } class RedBirdextendsBirdimplementsCloneable { // inherits properties from superclass public Object clone() {} // clone method } abstract class SpecialBirdextendsBirdimplementsCloneable { abstractspecialMove(); // {abstract method} executed on tap }

  21. Angry Birds class BlueBirdextendsSpecialBirdimplementsCloneable { specialMove() { } } class YellowBirdextendsSpecialBirdimplementsCloneable { specialMove() { } } class BlackBirdextendsSpecialBirdimplementsCloneable { specialMove() { } }

  22. Angry Birds abstract class Pig extendsSpriteimplementsCloneable { double health; public Object clone() {} // clone method }

  23. Angry Birds abstract class Pig extendsSpriteimplementsCloneable { double health; public Object clone() {} // clone method } class SmallPigextendsPigimplementsCloneable { // inherits properties from superclass }

  24. Angry Birds abstract class Pig extendsSpriteimplementsCloneable { double health; public Object clone() {} // clone method } class SmallPigextendsPigimplementsCloneable { // inherits properties from superclass } class MediumPig, BigPig, HelmetPig, KingPig, etc.

  25. Angry Birds abstract class Pig extendsSpriteimplementsCloneable { double health; public Object clone() {} // clone method } class SmallPigextendsPigimplementsCloneable { // inherits properties from superclass } class MediumPig, BigPig, HelmetPig, KingPig, etc. // each have their own images, sizes, etc.

  26. Angry Birds abstract class Barrier extendsSpriteimplementsCloneable { double strength, density, etc..; public Object clone() {} // clone method } class IceBarrier, WoodBarrier, StoneBarrier, etc. // each have their own images, sizes, etc.

  27. AngryBirds • One last class...

  28. AngryBirds • One last class... class Level implements ? { // what properties? }

  29. AngryBirds • One last class... class Level implementsCloneable { // what properties? publicObject clone() {…} }

  30. AngryBirds • One last class... class Level implementsCloneable { ArrayList<Bird> birds; ArrayList<Pig> pigs; ArrayList<Barrier> barriers; publicObject clone() {…} }

More Related