• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Exam question confusion - UML asks for print() method

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would really appreciate it if somebody could take a look at this. I've studying for an exam on Monday and am a little confused.

I'm working through previous exam papers and the first question always asks the student to write code based on a few UML diagrams.

Some of the classes usually contain methods for toString () and print ().

I can understand why the code should have a toString () method but I don't know what I'm supposed to do with the print() method..

See question 1 here for an example: http://exampapers.cit.ie/pastexams/Computing/KWEBD_8_Y1/2012%20Semester1/KWEBD_8_Y1%20SOFT7004%20Object%20Oriented%20Programming%201.pdf

Thanks.
 
Marshal
Posts: 80767
488
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

The answer is that whoever wrote those exam papers likes to have a print() method. I don't usually write them as a routine myself. Once you have a toString method you can probably write a print() method very simply like this:-I shall leave you to work out how that print() method works for yourself. It is really quite simple.
 
Pedro Hall
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Campbell
 
Campbell Ritchie
Marshal
Posts: 80767
488
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome
 
reply
    Bookmark Topic Watch Topic
  • New Topic