1 / 29

Lecture 8

COP3502: Introduction to CIS I. Lecture 8. i mperative programming. o bject-oriented programming. o bjects b uilding blocks of a program c ooperate to complete a task by sending messages. o bjects model tangible things c ars, schools, dogs . o bjects model conceptual things

spencer
Download Presentation

Lecture 8

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. COP3502: Introduction to CIS I Lecture 8

  2. imperative programming

  3. object-oriented programming

  4. objects building blocks of a program cooperate to complete a task by sending messages

  5. objects model tangible things cars, schools, dogs

  6. objects model conceptual things an event, a job

  7. objects model processes finding a path through a maze sorting a deck of cards

  8. using already made objects String Math Integer Array

  9. objects class “fancy variable”

  10. objects properties (“things that describe it”) capabilities (“things it can do”)

  11. capabilities (“behavior”) constructor – initialize object command – change an object’s properties query – send an object a message

  12. trash can constructor – can create itself commands – add trash, empty yourself query – Lid open or closed? How much trash?

  13. properties attributes – things that describe an object components – things that are “part” of an object association – things an object knows about

  14. object state set of all object properties

  15. objects in java properties – variables capabilities - functions

  16. Car properties: make, model, year, color capabilities: turn on, accelerate, brake, roll windows

  17. class vs. instance

  18. Class “Instances” of Class

  19. class Car { String make; String model; int year; String color; void Car() { … } void turnOn() { … } void accelerate() { … } void decelerate() { … } void rollWindows() { … } }

  20. class hello{ void main(String[] args) { … } }

  21. variables <type> <name> = <value>

  22. creating objects <class_name> <name> = new <class_name>() Car prius = new Car();

  23. class CarTest { void main(String[] args) { Car myMustang = new Car(); myMustang.make = “Ford”; myMustang.model = “Mustang”; myMustang.year = 1969 myMustang.color = “brown”; myMustang.turnOn(); myMustang.accelerate(); } }

  24. class CarTest { void main(String[] args) { Car myMustang = new Car(“Ford”, “Mustang”, 1969, “black”); myMustang.turnOn(); myMustang.accelerate(); } }

  25. interface

  26. interface LightBulb bulb = new LightBulb();

  27. interface LightBulb bulb = new LightBulb(); bulb.turnOn();

  28. problem solving with objects

More Related