• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to design classes  RSS feed

 
Abigail Decan
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i really have a lot of trouble coming up with class design problems such as

design a class to conduct a survey of three hospitals. you want to know how many sectors (eg operation, children, gastronomic) each hospitals have, and how many doctors there are in each sector.

what is the process of class design?
 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take your problem, and find out what entities are described. Here we have a Hospital, Sector and Doctor. Then determine their behaviour: Hospitals should return what sectors they are active in, and how many doctors they have on the payroll working in a particular sector. Doctors don't seem to have any behaviour, so you can leave out a Doctor class. That leaves you with the following:

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!