Create an Account

Already have account?

Forgot Your Password ?

Home / Questions / Create a Java application named Problem14 using the two files provided to you Date java an...

Create a Java application named Problem14 using the two files provided to you Date java and Problem14 java both located below then change the code to add a non-trivial public non-static method to

Create a Java application named Problem14 using the two files provided to you—Date.java and Problem14.java (both located below)—then change the code to add a non-trivial public, non-static method to the Date class (#1) .You must also transform the application program to “drive” Date to test your new method. #1. Increment a Date to the next day (for example, 1-31-2011 increments to 2-1-2011; 12-31-2010 increments to 1-1-2011). Notes Here, and other items below, “a Date” is the implicit parameter that this points to (OOPS! that this references). this is available in every non-static member function. Re-write the Date member functions Input() and Output() to use dialog boxes to accomplish input and output of Date objects. Run the program and make a screen shot. Post all modified source code for both Problem14.java and Date.java—and the screen shot of your program dialog that “proves” your code changes work correctly. //--------------------------------------------------------- // Date.java //--------------------------------------------------------- import java.util.Scanner; public class Date { private String name; private int MM; private int DD; private int YYYY; private char separator; //---------------------------------------------------- public Date(String name,char separator) //---------------------------------------------------- { this.name = name; DD = 1; MM = 12; this.YYYY = 1993; this.separator = separator; System.out.print("Date construction#1 of "); Output(); } //---------------------------------------------------- public Date(String name,int MM,int DD,int YYYY,char separator) //---------------------------------------------------- { this.name = name; this.DD = DD; this.MM = MM; this.YYYY = YYYY; this.separator = separator; System.out.print("Date construction#2 of "); Output(); } //---------------------------------------------------- public void finalize() //---------------------------------------------------- { System.out.print("Date destruction of "); Output(); } //------------------------------------------------- public void Input() //------------------------------------------------- { Scanner IN = new Scanner(System.in); System.out.print(name + " MM? "); MM = IN.nextInt(); System.out.print(name + " DD? "); DD = IN.nextInt(); System.out.print(name + " YYYY? "); YYYY = IN.nextInt(); } //---------------------------------------------------- public void Output() //---------------------------------------------------- System.out.printf("%s = %2d%c%2d%c%4d\n",name,MM,separator,DD,separator,YYYY); } //------------------------------------------------- public void SetMM(int MM) //------------------------------------------------- { this.MM = MM; } //------------------------------------------------- public void SetDD(int DD) //------------------------------------------------- { this.DD = DD; } //------------------------------------------------- public void SetYYYY(int YYYY) //------------------------------------------------- { this.YYYY = YYYY; } //------------------------------------------------- public String GetName() //------------------------------------------------- { return( name ); } //------------------------------------------------- public int GetMM() //------------------------------------------------- { return( MM ); } //------------------------------------------------- public int GetDD() //------------------------------------------------- { return( DD ); } //------------------------------------------------- public int GetYYYY //------------------------------------------------- { return( YYYY ); } //------------------------------------------------- public char GetSeparator() //------------------------------------------------- { return( separator ); } } //------------------------------------ extra answer is given below attachment

May 27 2020 View more View Less

Answer (Solved)

question Subscribe To Get Solution

Related Questions