



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
The concepts of object-oriented programming (oop) as taught in the cmpu-101 course at vassar college during the fall 2006 semester. It covers the idea and claim behind oop, the translation between real world, model, classes, information, and behavior, and the use of unified modeling language (uml) to describe and design classes and their relationships. The document also includes examples of classes like account, person, employee, and student, and explains the concepts of is-a and has-a relationships.
Typology: Assignments
1 / 5
This page cannot be seen from the preview
Don't miss anything!
CMPU-101: Problem-Solving and Abstraction Marc Smith (sect. 52) Vassar College Fall 2006 2
Idea: Programs should closely model the real world. Claim: Such programs are easier to write & maintain. Must be able to translate between:
Object-Oriented Design:
5
ClassName data methods A visual language for describing and designing classes and class relationships Two types of class relationships: is-a, has-a 6
Account owner balance accountNumber Account(…) — constructor getBalance deposit withdraw addInterest
Account owner balance accountNumber Account(…) getBalance deposit withdraw addInterest
Person name ssn dateOfBirth address Person(…) — constructor setName setAddress ! Employee dateHired monthlySalary
13
Account allows getBalance and withdraw. PrintStream allows print and println. 14
Student name ssn dateOfBirth gpa Sometimes in a UML diagram, we show only the fields of the class, depending on our purpose
Section roster instructor room timeSlot Section(…) — constructor addStudent(Student) removeStudent(Student) contains(Student) intersect(Section) In this case, roster is a collection of Student s - - a one-to-many, has-a relationship! (one Section has many Student s)
Composed of: letters digits underscore ("_") Must begin with a letter. Examples: timeToLive bistro U MAXIMUM_VALUE
17
Classes — all words are capitalized Account BankAccount ClosedCurve Matrix3By Instances — the first word is not capitalized cs numberOfStudents averageAge taxRate 18
Reserved words class, public, private, static, … (see Appendix Two) Names defined by other programmers in the API System.out, println, PrintStream Names we select
Given a problem, we must answer the questions: What are the classes? What are the methods? What are the instance variables? Written assignment: choose from Chapter 2 Exercises