• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exam question confusion - UML asks for print() method

 
Pedro Hall
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50277
80
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks Campbell
 
Campbell Ritchie
Sheriff
Pie
Posts: 50277
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic