1 / 9

You are a family which has many pets. You have 3 dogs, 2 cats, 2 hamsters,

Example: Problem statement. You are a family which has many pets. You have 3 dogs, 2 cats, 2 hamsters,

wgrady
Download Presentation

You are a family which has many pets. You have 3 dogs, 2 cats, 2 hamsters,

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. Example: Problem statement You are a family which has many pets. You have 3 dogs, 2 cats, 2 hamsters, a budgie and an iguana. All of these pets have to be taken to various vets at various times for their checkups or medical problems. Because you have so many pets, you have found it difficult to keep track of everything. You have decided that you want to write a program to help keep track of your various non-sapien housemates and their vet appointments. You would also like to be able to compute how much you have spent in vet bills for any given year. • What are the entities? • What are the objects? • What are the classes?

  2. Hamster Cat Cat Dog Hamster Dog Budgie Dog Iguana Appointment Appointment Appointment Appointment Vet #3 Vet #1 Vet #2

  3. Hamster Cat Cat Dog Hamster Dog Budgie Dog Iguana Appointment Appointment Appointment Appointment Vet #3 Vet #1 Vet #2

  4. Vets • What state information has to be maintained about a particular vet? • Name of the vet? • Address of the vet? • What the vet specializes in? • We identify all of the common features of the vets and we create a classification (i.e. class). Public class Vet { String name; String Address; String specialization; // method definitions here } Vet Name : String Address : String Specialization : String

  5. Appointment • What state information has to be maintained about a particular appointment? • Date of the appointment? • Which vet? • Which animal(s) are included as part of the appointment? • Results of the appointment? • Cost of the appointment? • We identify all of the common features of the appointments and we create a classification (i.e. class). Public class Appointment { Vet theVet; Date theDate; List patients; String result; Money cost; // method definitions here } Appointment Vet : Vet Date : Date Patients : List of animals Result : String Cost : Money

  6. Cats, Dogs, Budgie, Hamsters, Iguana • What information has to be kept about each pet? • Pet name • Pet species • Date of birth Public class Pet { String name; String species; Date dob; // method definitions here } Pet Name : String Species : String Dob : Date

  7. Class Diagram Pet Name : String Species : String Dob : Date Vet Name : String Address : String Specialization : String Appointment Vet : Vet Date : Date Patients : List of animals Result : String Cost : Money

  8. Pet Name: Killer Species: Hamster Dob: Jan 1, 2003 Pet Name: Diablo Species: Cat Dob: July 15, 1991 Pet Name: Angel Species: Cat Dob: July 27, 1993 Pet Name: Bloodfang Species:Dog Dob: Sept 13, 1997 Pet Name: Buttercup Species: Hamster Dob: Mar 15, 2004 Pet Name: Bounder Species:Dog Dob: Dec 15, 2001 Pet Name: Frisky Species:Dog Dob: May 23, 1993 Pet Name: Freddy Species: Budgie Dob: Apr 17, 2003 Pet Name: Herman Species: Iguana Dob: Feb 2, 1996 Appointment Date: Jan 25, 2005 Result: Antibiotics for Herman Cost: $45..00 Appointment Date: Jan 25, 2005 Result: Needs more gravel Cost: $50.00 Appointment Date: Jan 3, 2005 Result: Vaccines good,Recheck dental Cost: $150.00 Appointment Date: Jan 25, 2005 Result: Teeth cleaned Cost: $120.00 Vet Name: Dr. Vulpine Address: 123 Any street Specialization: Rodents Vet Name: Dr. Fluffy Address: 123 Any street Specialization: Rodents Vet Name: Dr. Canid Address: Dog leg Rd. Specialization: Dogs

  9. Problem solving process • Analyse problems for entities • These entities are objects • Classify those objects • Identify common features of objects • Create a classification which contains those common features • Give the class and appropriate name • During program execution: • Instantiate objects which represent real-world entities • Associate objects with other objects • Invoke methods against objects to utilize their behaviour

More Related