public class CalenderDay private int month; private int day; private int year; public CalenderDay(String date) {...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
public class CalenderDay private int month; private int day; private int year; public CalenderDay(String date) { String[] parts = date.split("/"); this month = Integer.parseInt(parts[0]); this.day= Integer.parseInt(parts[1]); this.year=Integer.parseInt(parts [2]); } public CalenderDay (int month, int day, int year){ this.month = month; } public CalenderDay (CalenderDay other){ this month = other.month; other. day; } this.day day; this.year = year; public int getMonth() { return month; this.day this.year = other.year; } public void setMonth(int month) { this.month = month; } public int getDay () { return day; } public void setDay (int day) { this.day day; } public int getYear() { return year; } } public void setYear(int year) { this.year = year; } @Override public boolean equals(Object o){ if(o instanceof CalenderDay) { CalenderDay other = (CalenderDay) o; return this.month == other.month && this.day == other.day && this.year == other.year; } else{ } return false; } @Override public String toString(){ } return month + "/" + day + "/" + year; File Edit Format View Help import java.util.Arrays; public class Main{ public static void main(String[] args) { // Christmas CalenderDay d1 = new CalenderDay ("12/25/2000"); // Thanksgiving CalenderDay d2 = new CalenderDay("11/24/2016"); // A copy of Thanksgiving CalenderDay d3 = new CalenderDay (d2); // 12/25/2000 Christmas System.out.println("d1: "+d1); "+ d2); // 11/24/2016 What day is it? System.out.println("d2: // 11/24/2016 copy System.out.println("d3: "+ d3); // false - different dates System.out.println("d1 // true - same dates System.out.println("d2 equals d3: equals d2: } + "d1.equals(d2)" + "False"); + "d2.equals(d3)" + "True"); CalenderDay [] days= new CalenderDay [3]; days [0] =new CalenderDay ("10/31/2015"); // Halloween days [1] =new CalenderDay("12/25/2000"); // Christmas days [2] =new CalenderDay("11/24/2016"); // Thanksgiving Arrays.sort (days); for (CalenderDay d: days) { System.out.println(d); public class CalenderDay private int month; private int day; private int year; public CalenderDay(String date) { String[] parts = date.split("/"); this month = Integer.parseInt(parts[0]); this.day= Integer.parseInt(parts[1]); this.year=Integer.parseInt(parts [2]); } public CalenderDay (int month, int day, int year){ this.month = month; } public CalenderDay (CalenderDay other){ this month = other.month; other. day; } this.day day; this.year = year; public int getMonth() { return month; this.day this.year = other.year; } public void setMonth(int month) { this.month = month; } public int getDay () { return day; } public void setDay (int day) { this.day day; } public int getYear() { return year; } } public void setYear(int year) { this.year = year; } @Override public boolean equals(Object o){ if(o instanceof CalenderDay) { CalenderDay other = (CalenderDay) o; return this.month == other.month && this.day == other.day && this.year == other.year; } else{ } return false; } @Override public String toString(){ } return month + "/" + day + "/" + year; File Edit Format View Help import java.util.Arrays; public class Main{ public static void main(String[] args) { // Christmas CalenderDay d1 = new CalenderDay ("12/25/2000"); // Thanksgiving CalenderDay d2 = new CalenderDay("11/24/2016"); // A copy of Thanksgiving CalenderDay d3 = new CalenderDay (d2); // 12/25/2000 Christmas System.out.println("d1: "+d1); "+ d2); // 11/24/2016 What day is it? System.out.println("d2: // 11/24/2016 copy System.out.println("d3: "+ d3); // false - different dates System.out.println("d1 // true - same dates System.out.println("d2 equals d3: equals d2: } + "d1.equals(d2)" + "False"); + "d2.equals(d3)" + "True"); CalenderDay [] days= new CalenderDay [3]; days [0] =new CalenderDay ("10/31/2015"); // Halloween days [1] =new CalenderDay("12/25/2000"); // Christmas days [2] =new CalenderDay("11/24/2016"); // Thanksgiving Arrays.sort (days); for (CalenderDay d: days) { System.out.println(d);
Expert Answer:
Related Book For
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates
Posted Date:
Students also viewed these programming questions
-
This question concerns lexical grammars. (a) Tree Adjoining Grammars contain two types of elementary tree. (i) What are these trees called? [1 mark] (ii) If one were building a grammar for English...
-
(a) Use the following text to derive distributions for rat and chased. Use a five-word window, including open- and closed- class words, ignore case, punctuation and sentence boundaries and weight...
-
You are currently a managing partner at Innovative Marketing Solutions (IMS) a social media marketing start-up. The firm occupies a modern office space at the London Roundhouse (a hub for tech...
-
A snow-making machine used for ski areas blows a mixture of compressed air and water through a nozzle. The temperature of the mixture may initially be well above the freezing temperature of water,...
-
Estimate the slope of each of the following curves at the designated point P. P
-
Use information from Section 6.7 to estimate which form of electromagnetic radiation is the lowest energy ionizing radiation. Data from section 6.7 When we first introduced the concept of the...
-
On March 20, Dodys petty cash fund of $100 is replenished when the fund contains $9 in cash and receipts for postage $52, freight-out $26, and travel expense $10. Give the journal entry to record the...
-
(a) Consider the recurrence below defined for n 0. 3 T(n): if n = 0 7T (n - 1) +12 if n > 0 Give a closed-form solution to the recurrence. You only have to give the solution. You do not need to show...
-
For more than 10 years you have been a human resources manager at a welding and machining company that has remained fairly stable. The business has 20-25 employees, most of whom have been with the...
-
A DC motor turns through 2 5 0 revolutions in 3 0 seconds. What is its average rotational velocity?
-
In five years, Kent Duncan will retire. He is exploring the possibility of opening a self-service car wash. The car wash could be managed in the free time he has available from his regular...
-
The following companies were listed on the SEM - 7 at 30.12.2015. The share prices at the 30.12.2005 and the number of shares outstanding at the same date are available. Price (Rs)No. at of Market...
-
A desk fan, initially spinning at 6 0 0 rpm , slows down to 2 0 0 rpm in 5 seconds. What is the magnitude of the fan's average rotational acceleration?
-
The expected interest rates on one-year bonds for the next 6 years are listed below. i = 6.25%, i=6%, +2=5.5%, i 1+1 = 5.5%, i 1+3 =5.25%, i (+4 1+5 The liquidity premiums for one-to six-year bonds...
-
The price of a first-class stamp in 1970 was 8 cents, whereas in 2002 it was 44 cents. The Consumer Price Index for 1970 was 38.8, whereas for 2002 it was 229.6. If the true cost of a first-class...
-
Use multiplication or division of power series to find the first three nonzero terms in the Maclaurin series for each function. y = e x2 cos x
-
Explain briefly the operation of each of the following Iterator-related methods: a) Iterator b) HasNext c) Next
-
In this chapter, we created the CommissionEmployeeBasePlusCommissionEmployee inheritance hierarchy to model the relationship between two types of employees and how to calculate the earnings for each....
-
The use of computers in education is referred to as computer-assisted instruction (CAI). Write a program that will help an elementary school student learn multiplication. Use a SecureRandom object to...
-
Define terrorism.
-
Congress has prohibited the provision of material support or resources to certain foreign organizations that engage in terrorist activity. 18 U.S.C. 2339B(a)(1) . . . The plaintiffs in this...
-
Following a six-day trial in March 2008, a jury convicted Defendant Hassan Abu-Jihaad on two charges: (1) disclosing national defense information to those not entitled to receive it in violation of...
Study smarter with the SolutionInn App