Question: Write a method called makeItNewYears that could be added to the class DateFirstTry in Display 4.1. The method makeItNewYears has no parameters and sets the
Write a method called makeItNewYears that could be added to the class DateFirstTry in Display 4.1. The method makeItNewYears has no parameters and sets the month instance variable to "January" and the day instance variable to 1. It does not change the year instance variable.
Display 4.1:
Display 4.1 A Simple Class This class definition goes in a DatePirstTry-java file named 1 public class DatePirstTry public String month public int day: public int year: //a four digit number Later in this chapter, we will see that these three public modifiers should be replaced withprivate. public void writeOutput ) System-out.printIn(month + + day + ". " + year) ; 10 1 publie class DateFirstTryDemoThis class definition (program) goes in a file named DatePirstTryDemo java public static void main (String[] args) DateFirstTry datel, date2; datelnew DateFirstTry) date2new DateFirstTry ) datel.month December"; datel.day31 datel.year- 2012; System. out . printin ( date 1 : " ) ; datel.writeOutput ) 10 14 15 16 17 18 19 date2.monthJuly" date2.day4 date2.year 1776; System. out . print In ( "date2 : " ) ; date2.writeOutput ) Sample Dialogue datel: December 31, 2012 date2: July 4, 1776
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
