Returning the next day?

Hi, i hope somebody can help me, I'm new to Java and I'm stuck with some work that I am doing. I don't want an answer, just a hint as to where to get started.
I have created a class called Date, which uses switch statements to return a string of the date, when integer values are entered. I need to define a method public Date nextDay() to compute the next day, but I have no idea how to even start.
Here's the code in my original class, I need to emphasise that I do not want an answer, but a suggestion as to how to get started, I don't really understand what is meant by I need to have a return value of type Date because I do not really understand how this type would be represented.
package dates;
public class Date {
       Constructs a date with a given year, month, and day
       of the calendar.
       @param year a year between 94 and 07
       @param month a month between 1 and 12
       @param day a day between 1 and 31
    private int day, month, year;
    public Date(int d, int m, int y)
        day = d;
        month = m;
        year = y;
    public void setDay(int d)
        day = d;
       Returns the day of this date
       @return the day
    public String getDay()
        String sDay = "day";
        switch (day) {
            case 1: case 21: case 31:
                sDay = day+ "st"; break;
            case 2: case 22:
                sDay =day + "nd"; break;
            case 3: case 23:
                sDay = day+"rd"; break;
            case  4: case  5: case  6: case  7: case  8: case  9: case 10: case 11: case 12:
            case 14: case 15: case 16: case 17: case 18: case 19: case 20:
            case 24: case 25: case 26: case 27: case 28: case 29: case 30:
                sDay =day+ "th"; break;
            default: System.out.println("Please enter a valid date");
        return sDay;
    public void setMonth(int m)
        month = m;
       Returns the month of this date
       @return the month
    public String getMonth ()
        String sMonth = "";
        switch (month) {
            case 1: sMonth = "January"; break;
            case 2: sMonth = "February"; break;
            case 3: sMonth = "March"; break;
            case 4: sMonth = "April"; break;
            case 5: sMonth = "May"; break;
            case 6: sMonth = "June"; break;
            case 7: sMonth = "July"; break;
            case 8: sMonth = "August"; break;
            case 9: sMonth = "September"; break;
            case 10: sMonth = "October"; break;
            case 11: sMonth = "November"; break;
            case 12: sMonth = "December"; break;
            default: System.out.println("Please enter a valid month");
        return sMonth;
    public void setYear(int y)
        year = y;
       Returns the year of this date
       @return the year
    public int getYear ()
        int sYear = year;
        switch (year) {
            case 90: sYear = 1990; break;
            case 91: sYear = 1991; break;
            case 92: sYear = 1992; break;
            case 93: sYear = 1993; break;
            case 94: sYear = 1994; break;
            case 95: sYear = 1995; break;
            case 96: sYear = 1996; break;
            case 97: sYear = 1997; break;
            case 98: sYear = 1998; break;
            case 99: sYear = 1999; break;
            case 00: sYear = 2000; break;
            case 01: sYear = 2001; break;
            case 02: sYear = 2002; break;
            case 03: sYear = 2003; break;
            case 04: sYear = 2004; break;
            case 05: sYear = 2005; break;
            case 06: sYear = 2006; break;
            case 07: sYear = 2007; break;
            default: System.out.println("Please enter a valid year");
        return sYear;
    public String toString()
        return getDay()+" "+getMonth()+" "+getYear();
}

Well I'm sure that any basic java tutorial that included the words "object" and "create" would be able to help you, but I showed you above how to create a Date. See reply #2.
The general syntax for creating a new Object has two parts. First, you must declare a reference to the object:
Object myObject;Then you must instantiate a new object:
myObject = new Object();  //this must match a valid constructor for your type (in your case Date) You can of course do this in one line:
Object myObject = new Object();And for you, you want to use a subclass of Object, named Date (which is what you've called your class)
public Date returnNewDate() { //just a SAMPLE method returning a new Date object
Date date = new Date(10,12,2007);
return date;
}

Similar Messages

  • I have now transfered my files of ripped CD's to my iTunes library three times. On each occassion, the conversion seems to occur fine, the files play, but when I close my computer and return the next day, iTunes says it cannot locate any of those files.

    I have now transfered my files of ripped CD's to my iTunes library three times Since upgrading to iTunes 11 and Windows 8. On each occassion, the conversion seems to occur fine, the files play, but when I close my computer and return the next day, iTunes says it cannot locate any of those files. Three times. Beginning to lose my temper. Advice? Suggestions? Could the fact that my original library is located on a network drive have anything to do with it? Thanks for your help, all.

    Repair security permissions
    Right-click on your main iTunes folder and click Properties, then go to the Security tab and click Advanced. If necessary grant your account and system full control to this folder, subfolders and files, then tick the option to replace permissions on child objects which will repair permissions throughout the library. This is the XP dialog but Windows 7/8 shouldn't be too different.
    Repeat for the media folder if it isn't a subfolder of the iTunes folder.
    tt2

  • I NEED HELP!! Been calling since the end of Nov and being charged for a Warranty device. The device was returned the next day!! Been calling twice a week.. NEED RESOLUTION

    I NEED HELP!! Been calling since the end of Nov and being charged for a Warranty device. The device was returned the next day!! Been calling twice a week.. I NEED HELP 6 TCC TICKETS HAVE BEEN OPENED - PROMISED CALLS BACK AND NEVER GET CALLS.
    About to cancel my account and move to AT&T
    TCC TICKETS:  (removed)
    I am trying here for the last resort. After this evening my account along with my business account will be cancelled. Total lines that Verizon will have lost will be 93 lines.
    PLEASE SOMEONE JUST HELP ME!!!!
    I already tweeted and facebook messaged Verizon. Your CS group has gone down hill over the last 3-6 months. I use to enjoy being a customer.
    >> Edited to comply with the Verizon Wireless Terms of Service <<

    not all the lines have ETF's. I have 30 tablets and the rest phones. The phones have ETFs and the tablets are all month to month.
    The total to move my account over is going to come out to about $8500.
    Rep has been trying to get my business for years.  I was always loyal to Verizon until this happened.

  • I purchased a Belkin MDP to HDMI cable 4M and found mine the next day. Can I return it to the store. I have the box and receipt.

    I purchased a Belkin MDP to HDMI cable 4M and found mine the next day. Can I return it to the store. I have the box and receipt.

    I believe you can.

  • Flight log time calulation when time passes to the next day.

    I am converting an excel spreadsheet to numbers for use on my iPad. I have a flight log that records various flight information. One of the calculations is flight time. Currently, using excel, I am able to put a start time in a cell, let's say c6, with a value of 19:09. The next cell over, let's say, d6 has the ending time with a value of 01:03. Therefore, the flight time calculated should be 5hrs 54 min, or 5.9 hours. I would need numbers to calculate the total flight time. Note that the date has changed, the flight departed at 19:09 and landed after midnight, herein lies the problem. If the flight departs and lands the same day I have no issues, however, when the flight lands the next day the formula is incorrect. If it's any help here is the excel formula I use;
    =IF(H6>0,(IF(H6>0,(IF(H6<I6,-(((H6-INT(H6))24)-((I6-INT(I6))*24)),((((I6-H6)*1)24)+24))),)),"-")
    Any help would be greatly appreciated. Anyone in the Phoenix area may get a free flight if you provide a great deal of assistance.
    Thanks Ryan

    Assuming that Date and Time values are handled the same way in Numbers for iPad as in Numbers '09,
    You need to include the Date information for times of days other than the day they are entered.
    Any cell displaying either Time or Date information actually contains a Date and Time value. If you entered only the Time portion of that value, the Date portion is automatically set to Today's Date.
    If you enter only the Date portion of the value, the Time portion is automatically set to 00:00:00 (midnight).
    So for a flight starting today (July 29) at 19:09, and ending tomorrow (July 30) at 01:03, Numbers will return a negative result if no date is specified for the landing time (unless that time is entered tomorrow, of course).
    Solution 1:
    Format C6 and D6 to show Time and Date, and enter both where the date involved is not the date the information is entered.
    Solution 2:
    If all details are entered on the same day AND no flight lasts more than 23h 59m, the following formula will correct for ending times 'earlier' than starting times:
    =IF(D6>C6,D6-C6,D6+1-C6)
    Regards,
    Barry

  • Since latest ios update, my iphone 6 loses my ringtones. I download new and that's gone the next day too

    Since latest ios update, my iphone 6 loses my ringtones. I download new and that's gone the next day too. How can I get my phone to keep my ringtones?

    Most USB port do not supply enough current to charge the iPad.

  • I requested a repair, but there was an error after clicking the button with my credit card info. I was still charged, but the form email I received the next day had incorrect info about my iPod Touch problem. How can I contact CS w/o paying $19?!

    My iPod Touch battery is not working. I requested a repair through the Apple Support. On the final page, when I clicked the button that puts the info through with your credit card number, the resulting page gave an error (I wish I'd have saved it!). Anyhow, I checked my credit card and it was charged, so I assumed the repair request went through. The next day I received a form email saying my problem was with "Sync with iTunes (Not iCloud) - Data Backup/Migration (not iCloud)" instead of the battery repair. It also says for iPod customers, to send your iPod to Apple - but I had requested the "iPod Coffin" to be mailed to me so I could send it back. Obviously there was an error between the request and what was received, so I'd like to ask Customer Service about it. However, I can't find a way to contact them. When I replied to that form email, I recieved an automated reply saying emails there were not read. Anything online asks me to pay $19 and I don't have the correct issues to request an exception. The closest store is over an hour away or I'd simply go there to ask. What can I do?! Any suggestions you have are much appreciated. Thank you!
    PS - The form email also says if I wait 10 days the repair request will be canceled. Does this mean my credit card will be refunded for the $85 battery replacement charge if it is canceled automatically?

    Thanks, but I've been on the phone with AppleCare US (where I am and live) and AppleCare UK. They continue bouncing me back and forth without helping resolve the problem.
    Perhaps someones knows how to further escalate the issue at Apple?

  • After updating to the latest version, I'm able to open and use the browser for one day. The next day, the browser doesn't not open up. please help!!!

    -reformatted computer, reinstalled everything
    -downloaded the newest version of mozilla
    -happily went online for one day
    -next day, browser does not load
    -later the next day, browser doesn't even open up
    -now when i go to open mozilla, something like this shows up:
    "server busy, taking too long...if your firewall is on make sure mozilla is allowed to browse...adjust proxy settings blah blah...

    HI Juanverano,
    Not a problem, Safe Mode will disable addons and hardware acceleration. If this continues and it is not an add on this will be the next step to try to disable acceleration:
    Try disabling graphics hardware acceleration. Since this feature was added to Firefox, it has gradually improved, but there still are a few glitches.
    You might need to restart Firefox in order for this to take effect, so save all work first (e.g., mail you are composing, online documents you're editing, etc.).
    Then perform these steps:
    #Open Firefox ''Options'' window (''Preferences'' on Mac or Linux) as follows:
    #* In Firefox 29.0 and above, click the menu button [[Image:New Fx Menu]] and select ''Options'' for Windows or ''Preferences'' on Mac or Linux.
    #* In Firefox 28.0 and previous versions, click the orange Firefox button at the top left, then select the "Options" button, or, if there is no Firefox button at the top, go to Tools > Options.
    #In the Firefox Options (or Preferences) window, click the ''Advanced'' tab, then select ''General''.
    #In the settings list, you should find the ''Use hardware acceleration when available'' checkbox. Uncheck this checkbox.
    #Now, restart Firefox and see if the problems persist.
    Additionally, please check for updates for your graphics driver by following the steps mentioned in the following Knowledge base articles:
    * [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]]
    * [[Upgrade your graphics drivers to use hardware acceleration and WebGL]]
    Did this fix your problems? Please report back to us!
    Thank you.

  • I gave my ipad 2 to my brother last month. After that he erased all content and settings, sign in with his apple id. The next day until now, I found out that I can not udpate my apps both on my iPhone and iPad Air. What should I do? Thank you in advance.

    I gave my ipad 2 to my brother last month. After that he erased all content and settings, sign in with his apple id. The next day until now, I found out that I can not udpate my apps both on my iPhone and iPad Air. I had create new apple id, change my password, delete the icloud acc. But still I can not update my apps. I have many of red notifications on iPhone and iPad Air. What should I do? Thank you in advance.

    1. It is never a good idea to include personal info like your email address or Apple ID in a post on an open forum.
    2. The email you received DOES NOT say your Apple ID cannot be used to unlock this iPad. The email informs you that your Apple ID was used to unlock an iPad. Fortunately the iPad is yours. The message confirms that. If your Apple ID was used to unlock an iPad that was not yours your would then know to change your password. Since the iPad is yours you do not need to change your password.
    Is your iPad working?

  • My IPhone 5 will not turn on, I had a new screen I stalled, all working great, the next day I was flying so turn off the phone and since trying to turn back in again,,, I receive many lines of white text stating incorrect shutdown please help

    hhello, please help if you can,,,
    i had a new screen installed, everything working fine, as was using the phone, the next day I was flying so turn off the phone in the usual way...
    oon arrival turned the phone on, received a slow acting black background with the apple sign visual, but never moved from that......... So tried a reset still the same just left looking at the apple sing in the middle if the screen,makes it there for 5 mins but still never turn on completely,,,,,
    again I tried,,,,,, again I tried a reset, then started to received lines of white writing, about 4-5 lines slowly like it was being typed, which stateed INCORRECT SHUTDOWN, ????????? then took out my MacBook air, to connect to ITunes to see whaypt I could do,
    i tunes did not find the phone as would normally so opened ITunes manually, still did not find the Iphone,,,,,
    Any Ideas please, as it is useless stuck in the drawer, I am an apple user, an quite knowledgable having other Iphine 5, IPad air and Mac,,,,, I am stuck,,,,
    PLease Help,my hank you in advance

    SharmFarm wrote:
    Good ev Ning Mario49    firstly I would like to say a great thank you for your attention to trying to help me,,,,,    i have looked at the links and will try everything stated first thing…
    Hi Mario,,,,
    I tried everything in your reply,,, thank you again,, I had done that once before and all was working great,,
    I have just now tried the Reinstall via iTunes, about 20 into the download, the iTunes logo on the phone disappeared, and the Apple Logo appeared again,,, I waited until the iTunes stated that the download had finished, and the install was in progress,,,
    Nothing happened, still the Apple Logo was visual on the screen, iTunes never recognised the phone which it was on my iTunes account previously,,,
    Still just a bunch of lines, maybe 5 or 6 so small writing,, I personally can not read what it is telling me, someone said it reads, incorrect shutdown,,,????????
    Please advise,???
    I am now at a loss,,, I really became excited when I saw the iTunes icon after putting the phone into restore,,,???
    Thank you again
    D

  • My itunes wont auto sync my iphone 4 after i connect it to itunes. But it can auto sync when i connect it to my old laptop. what's the problem that it can't auto sync and when i did a backup in my new laptop, it was corrupted the next day.

    But it can auto sync when i connect it to my old laptop. what's the problem that it can't auto sync and when i did a backup in my new laptop, it was corrupted the next day and i was forced to use back a backup which i did in my old laptop 4 months ago. do i have to reinstall the itunes? will my backups be corrupted after i sync again? pls guide.
    P.S/ its the latest version of the itunes whenever i did the backups.

    iPod touches or any iDevices from Apple sync only to one computer. If you sync to a different computer, all your music will be replace with the music from the new computer's iTunes. If the music were purchased from iTunes, you can re-download them again otherwise the music on iPod touch will be deleted. Do you have iTunes backup? 

  • Itunes match deletes random songs from my iphone, even if i re download them from the cloud, the next day another 3 or 4 are deleted by itself, anyone know a fix?

    anybody know how i can fix this, i already tried to turn off itunes match off and on again on the iphone but it does not seem to work, also artwork once downloaded into the iphone it does not stay there, the next day its just a blank artwork and after the internet circles in the top left of the iphone stop spinning, i go back to my music library and then back to the song and it downloads it, but it does not stay there forever, any fix?
    it would be kindly appreciated since this is a very annoying bug, specially the songs that just get erased from my iphone for no reason.

    Hi Kevinpnb,
    Welcome to the Support Communities!
    Sorry to hear of your frustration with Music Match on your iPhone.  You should be able to delete the music from your iPhone by following the steps in this article:
    iTunes Match on iPhone, iPad, or iPod touch
    http://support.apple.com/kb/HT5637
    Deleting songs downloaded to your device
    You can delete a song or album from your iPhone, iPad, or iPod touch at any time. Don't worry; it'll still be in the cloud.
    Tap the Music app.
    Tap More > Songs at the bottom.
    Scroll or search for the song you would like to delete from your device.
    Swipe right to left on the song, and then tap Delete.
    Note: You must be in Artists, Songs, or Albums view to delete songs from your device. Deleting from a playlist won't remove a song from your iOS device.
    Also, this information can be found on page 64 of the iPhone User Guide for iOS 7
    http://manuals.info.apple.com/MANUALS/1000/MA1565/en_US/iphone_user_guide.pdf
    Remove a song from iPhone. Tap Songs, swipe the song, then tap Delete. The song is deleted from iPhone, but not from your iTunes library on your Mac or PC, or from iCloud.
    If you have iOS 7, this will delete the song from local storage, but the song will still appear with a cloud symbol in the Music app, as you've noticed. To hide the iTunes in the Cloud purchases, navigate to Settings > iTunes & App Store, and disable "Show All: Music”
    There may be a few orphaned songs on your iPhone that were partially downloaded or corrupted in some way. If that is the case, you can erase all of the music from your phone.  Follow the instructions below and select the Music app under Usage:
    iPhone, iPad, and iPod: Understanding capacity
    http://support.apple.com/kb/ht1867
    If the issue still persists, try backing up your iPhone to iCloud, and then restore it:
    iCloud: Restore your iOS device from iCloud
    https://support.apple.com/kb/ph12521
    I hope this information helps ....
    - Judy

  • I got my iPhone stolen at a party, the next day my friend gave me back my iPhone 4s and he said that it was jailbroken. Now it will not turn on. When i plug it in to a charger, the apple logo appears for about ten second, then connect to iTunes stays on.

    Hello, i have a question on my iphone 4s. I went to a party a few days ago and it had gotten stolen. The next day my friend said that he had found it and it was jaibroken? The phone was on 1 % when i had recieved it. It then died and i plugged it in to the charger. When i plugged it in the apple logo appeared as if it was starting but, it wasnt. The apple logo appeared for about ten seconds and then the screen went black. After that, the connect to itunes screen popped up and will not go away. So now when i take it off of the charger the screen just stays black and wont turn on? I tried connecting it to itunes and restoring it. But it wont even show my phone any more on the side of itunes. I tried restoring it and an error had occured (2001). I have looked up on youtube how to fix this problem and non of them have helped or worked. Its my only phone and i cant even text my girlfriend which bothers me terribly!! Please help me ASAP!!

    The terms of service of the Apple Support Communities prevent us from helping anyone with a jailbroken phone.
    You're on your own.  Good luck.

  • I have Win XP on a Dell 9100. I had FF 3.6.10 & tried many times to upgrade to 3.6.11 --- all unsuccessful. The next day, I saw 3.6.12 downloading. I seem to now have 3.6.12 . I don't know about 3.6.11 . How can I check on this?

    I have had Mozilla Firefox for years. My computer is a Dell 9100 , and I use Windows XP. I have upgraded to each version of Firefox that was offered to me. Each upgrade was quick and easily done--up to, and including, Firefox 3.6.10 . I tried many times to upgrade to Firefox 3.6.11 , each time with no success. I have something like 21 copies of the downloaded Firefox 3.6.11 package. The next day, I resumed by quest to download & install 3.6.11 and saw, on my monitor, the 3.6.12 version of Firefox downloading. I don't recall how this happened. I know that I was only trying to download and install version 3.6.11 . Now, I seem to have, by looking at "About Mozilla Firefox" under "Help", Firefox 3.6.12 .
    Q1. Is there a way I can check to see whether I have a valid download of 3.6.11 and/or 3.6.12 in my Firefox setup?
    Q2. How can I know that all is OK, Firefox-wise? The answer to this question probably can help me a lot, in the future.
    Q3. Can I delete all, or perhaps all but one, of those 3.6.11 downloads?
    Q4. Any idea on why my difficulties occurred?
    Q5. How might I avoid these difficulties in the future?
    Thank you for your help.

    Firefox 3.6.12 is the current version and it was released only a few days after the release of Firefox 3.6.11 to fix a critical security issue that was discovered. The security fix was prepared and released within 48 hours after discovery.
    I do not know what caused your problems in trying to upgrade to Firefox 3.6.11, but the point is moot now. Should you have future problems upgrading, please post back here and someone will assist you.
    You can keep one copy of version 3.6.11 if you wish; I usually keep 2 prior versions plus the current version.
    You can download the full version(s), not just the small update, from: ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/
    <br />
    The information submitted with your question indicates that you have out of date plugins with known security issues that should be updated. To see the plugins submitted with your question, click "More system details..." to the right of your original question post.
    * Adobe PDF Plug-In For Firefox and Netscape
    * Next Generation Java Plug-in 1.6.0_21 for Mozilla browsers
    #'''Check your plugin versions''': http://www.mozilla.com/en-US/plugincheck/
    #*'''Note: plugin check page does not have information on all plugin versions'''
    #'''Update Adobe Reader (PDF plugin):'''
    #*From within your existing Adobe Reader ('''<u>if you have it already installed</u>'''):
    #**Open the Adobe Reader program from your Programs list
    #**Click Help > Check for Updates
    #**Follow the prompts for updating
    #**If this method works for you, skip the "Download complete installer" section below and proceed to "After the installation" below
    #*Download complete installer ('''if you do <u>NOT</u> have Adobe Reader installed'''):
    #**Use Firefox to download and SAVE the installer to your hard drive from the link in the article below
    #**On the Adobe page, un-check any extra items (i.e. Free McAfee® Security Scan Plus) then click Download button
    #**If you see message just under tabs, DO NOT click the Allow button, instead click below that where it says "click here to download".
    #**Click "Save to File"; save to your Desktop (so you can find it)
    #**After download completes, close Firefox
    #**Click the installer you just downloaded and allow the install to continue
    #***Note: Vista and Win7 users may need to right-click the installer and choose "Run as Administrator"
    #**'''<u>Download link and more information</u>''': https://support.mozilla.com/en-US/kb/Using+the+Adobe+Reader+plugin+with+Firefox#Installing_and_updating_Adobe_Reader
    #*After the installation, start Firefox and check your version again.
    #'''Update Java:'''
    #* Download and update instructions: https://support.mozilla.com/en-US/kb/Using+the+Java+plugin+with+Firefox
    #* Removing old versions (if needed): http://www.java.com/en/download/faq/remove_olderversions.xml
    #* Remove multiple Java Console extensions (if needed): http://kb.mozillazine.org/Java#Multiple_Java_Console_extensions
    #* After the installation, start Firefox and check your version again.

  • Can`t finish watching movie after I`ve paid for it the next day, get ~content require HDCP for playback~, but everything else works

    I`ve had a problem where I`ve purchased a movie via apple tv, watched half of the movie, then tried to watch he end the next day (before the thing expires), and i get a "...need HDCP for feedback", although everything else on the apple tv works fine (i.e previews of other movies, picks up comuters, netflix etc.

    Thank you for your help. Now my notebook (gt60-2oc) is perfect. I am the happiest person in the world .
    I followed these steps: topic=250946.0
    And the file I used is this :
    drive.google.com/file/d/0B5MQU_zcEPWTbTJjSkdlS01xc0k/view?usp=sharing
    Thanks again to all .

Maybe you are looking for