r/javahelp • • Nov 17 '19

How do I implement those two function?

Date is a class name. It contains three private datatype int day, month, year.

m. Return a reference to the object containing a copy of the date.

n. Make a copy of another date. Given a reference to an object containing a date, copy the data members of the object into the corresponding data members of this object.

Please give me an example how the function prototype should look like.

Edit:

I have to implement all the method here : http://prntscr.com/py9chy

I almost done except for m and n. Here is my work: https://pastebin.com/JnqhYzBA

0 Upvotes

5 comments sorted by

3

u/sozesghost Nov 17 '19

What have you tried so far? Homework questions (which this clearly is) require so effort on your part.

0

u/TD123TD Nov 17 '19

Yes I did.

1

u/[deleted] Nov 17 '19 edited Nov 17 '19

Why not write a class called Date that has three private datatype int day, month, year? Then create objects of that class? Use getters of the "date" class to create the second object, thereby "copying" the information from a previous "date" object?

0

u/TD123TD Nov 17 '19

Updated

1

u/AutoModerator Nov 17 '19

It seems that you possibly have a screenshot of code in your post How do I implement those two function? in /r/javahelp.

Screenshots of code instead of actual code text is against the Code posting rules of /r/javahelp as is also outlined in the sidebar - Code posting.

  • Never submit screenshots of code instead of code text!

If you posted an image merely to illustrate something, kindly ignore this message and do not repost. Your post is still visible to others. I am a bot and cannot distinguish between code screenshots and other images.

If you indeed did this wrong, please edit the post so that it uses one of the approved means of posting code.

  • For small bits of code (less than 50 lines in total, single classes only),
    the default code formatter is fine
    (one blank line before the code, then 4 spaces before each line of code).

  • Pastebin for programs that consist of a single class only

  • Gist for multi-class programs, or programs that require additional files

  • Github or Bitbucket repositories are also perfectly fine as are other dedicated source code hosting sites.

  • Ideone for executable code snippets that use only the console

Please do not reply to this message, because I am a bot. Talk-to-the-bot is the new talk-to-the-hand. If you instead want the classic talk-to-the-hand, just message the moderators. ;)

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.