• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

model class

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to do this and I have no clue...
I have to design, implement, and document three observers and one model. The model class stores and maintains a one-dimensional set
of data. The three observer classes display the data in different forms such as a one-column spreadsheet, a pie chart, a bar
chart, or text output. I need to use the Java graphics library to implement all of these observers as a part of one Java stand-alone application. At least one of the observers should be used to input data. The other two observers may be restricted to output only.
Thanks
 
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is it you're confused about? The whole oberver-observable thing or implementing the graphical observers?
If you need to find out about observable stuff you'd probably be best of checking out a book on design patterns - it's also called 'publish-subscribe'.
Here's what I remenber: Basically, there is a class which holds data, and one or more other classes that observe it.
When the observed class's data gets changed, it tells all the observers this, and sends them the new data.
normally the observed class would have an array (or similar) of pointers to 'observers'. To be notified about changes (to observe the class), an observing class would have to 'register' itself with the observed class (the observed class would need some method to register observers).
Then, whenever the observed class's data changed, it woulld go through it's registered observers and let them know. It may send it's new data at the same time, or (as is ususally the case) it might be down to the observer to get the data.
To implement this in Java, you might want to check out the Observable class and the Observer interface.
 
get schwifty. tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic