CSE 3302 Programming LanguagesCorrection of example in lecture 15HW3An ExampleSlide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11CSE 3302 Programming LanguagesChengkai LiSpring 2008Smalltalk(cont.)Lecture 16 – OO Programming, Spring 20081CSE3302 Programming Languages, UT-Arlington ©Chengkai Li, 2008Correction of example in lecture 15A>>m2….A subclass: #B … (not “B subclass: #A …”)B>>m2super m2B subclass: #C…C>>m1self m2aC := C new.aC m1What will happen if the lookup of m2 starts from the superclass of message receiver?Lecture 16 – OO Programming, Spring 2008CSE3302 Programming Languages, UT-Arlington ©Chengkai Li, 20082HW3Array:•reverse•maxLecture 16 – OO Programming, Spring 2008CSE3302 Programming Languages, UT-Arlington ©Chengkai Li, 20083An ExampleA library has books and clients. •Client: an ID, a name, an address and a collection of the books checked out. •Book: an ID, a title, an author, and a current state, which is either “checked out“ or “on shelf”.•Library: a collection of customers and a collection of books that are not checked out.Lecture 16 – OO Programming, Spring 2008CSE3302 Programming Languages, UT-Arlington ©Chengkai Li, 20084•Define three classes Library, Book, and Client. Lecture 16 – OO Programming, Spring 2008CSE3302 Programming Languages, UT-Arlington ©Chengkai Li, 20085•Define the initialization methods for these three classes.Lecture 16 – OO Programming, Spring 2008CSE3302 Programming Languages, UT-Arlington ©Chengkai Li, 20086•Define an allBooksDo: method for Library that iterates over both the books that are checked out and the books that are not checked out.Lecture 16 – OO Programming, Spring 2008CSE3302 Programming Languages, UT-Arlington ©Chengkai Li, 20087•Define a booksTitled: method for Library that returns a collection of all books with a particular title.Lecture 16 – OO Programming, Spring 2008CSE3302 Programming Languages, UT-Arlington ©Chengkai Li, 20088•Define the checkOut: method for Client, which takes a book as an argument and assigns to to the client.Lecture 16 – OO Programming, Spring 2008CSE3302 Programming Languages, UT-Arlington ©Chengkai Li, 20089•Define the checkoutBy: method for Book, which is only called if the book is not checked out. Its argument is the client checking out the book.Lecture 16 – OO Programming, Spring 2008CSE3302 Programming Languages, UT-Arlington ©Chengkai Li, 200810•Define the customer:checksOut: method for Library, which takes a client and a book and records the fact that the client checks out the book. It should check that the book is free before letting the client to check out.Lecture 16 – OO Programming, Spring 2008CSE3302 Programming Languages, UT-Arlington ©Chengkai Li,
View Full Document