Example Problem statement You are a family which

  • Slides: 9
Download presentation
Example: Problem statement You are a family which has many pets. You have 3

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? ●

Hamster Cat Dog Hamster Dog Budgie Dog Appointment Vet #3 Appointment Iguana Appointment Vet

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

Hamster Cat Dog Hamster Dog Budgie Dog Appointment Vet #3 Appointment Iguana Appointment Vet

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

Vets ● What state information has to be maintained about a particular vet? ●Name

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). ● Vet Name Address Specialization : String Public class Vet { String name; String Address; String specialization; // method definitions here }

Appointment What state information has to be maintained about a particular appointment? ●Date of

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 class Appointment create a classification (i. e. class). Public { ● Vet the. Vet; Date the. Date; List patients; String result; Money cost; Appointment Vet Date Patients Result Cost : Vet : Date : List of animals : String : Money // method definitions here }

Cats, Dogs, Budgie, Hamsters, Iguana ● What information has to be kept about each

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; Pet Name Species Dob : String : Date // method definitions here }

Class Diagram Vet Name Address Specialization Pet Appointment : String Vet Date Patients Result

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

Pet Name: Killer Species: Hamster Dob: Jan 1, 2003 Pet Name: Buttercup Species: Hamster

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

Problem solving process ● ● ● Analyse problems for entities ●These entities are objects

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