public class Date {   privateintyear; privateintmonth; privateintday;   public Date() {   }   public Date(intyear, intmonth, intday) { this.year = year; this.month = month; this.day = day;   }   publicint getYear() { returnyear; }   publicint getMonth() { returnmonth; }   publicint getDay() { returnday; }   @Override public String toString() { return"Date [year=" + year + ", month=" + month + ", day=" + day + "]"; }   } public class Date {   privateintyear; privateintmonth; privateintday;   public Date() {   }   public Date(intyear, intmonth, intday) { this.year = year; this.month = month; this.day = day;   }   publicint getYear() { returnyear; }   publicint getMonth() { returnmonth; }   publicint getDay() { returnday; }   @Override public String toString() { return"Date [year=" + year + ", month=" + month + ", day=" + day + "]"; }   } public class Date {   privateintyear; privateintmonth; privateintday;   public Date() {   }   public Date(intyear, intmonth, intday) { this.year = year; this.month = month; this.day = day;   }   publicint getYear() { returnyear; }   publicint getMonth() { returnmonth; }   publicint getDay() { returnday; }   @Override public String toString() { return"Date [year=" + year + ", month=" + month + ", day=" + day + "]"; }   } public class Mailbox {   private String client; private Email[] emails; privateintactualSize;   /** * Default Constructor creates new Email array with maximum of 15 email's sets * the client to Brad's inbox. */ public Mailbox() { this.emails = new Email[15]; actualSize = 0; this.client = "Brad's inbox"; }   /** * * @param client calls the default consturctor sets client to client set in * Default Constructor */ public Mailbox(String client) {   this(); this.client = client;   }   /** * * @return the email client */ public String getClient() { returnclient; }   /** * * @return emails from emails Array */ public Email[] getEmails() { returnemails; }   /** * * @return how many emails are in inbox */ publicint getActualSize() { returnactualSize; }   /** * * @param email If there is no capacity there is a message to upgrade account If * not it adds to how many emails till maximum capacity is reached */ publicvoid addEmail(Email email) { if (this.actualSize >= 15) { System.out.println("You have reached maximum capacity. Upgrade your account. "); } else { emails[actualSize] = email; actualSize++; } }   publicvoid sortEmailsByDate() {   }   /** * * @param year email was received * @return email from year and returns emails that match */ public Email findEmail(intyear) { for (inti = 0; i < this.actualSize; i++) { if (this.emails[i].getDate().getYear() == year) { returnthis.emails[i]; } } returnnull; }   /** * * @return number of urgent emails */ publicint countUrgent() { intnumberOfEmails = 0;   for (inti = 0; i < this.actualSize; i++) { if (this.emails[i].isUrgent()) { numberOfEmails++; } }   returnnumberOfEmails; }   /** * toString method that returns the client, the urgent emails, and the number of * emails */ @Override public String toString() { String mailboxInformation = "Mailbox for " + client + " - Urgent emails: " + countUrgent() + " - Emails:\n";   for (inti = 0; i < actualSize; i++) { mailboxInformation += emails[i].toString() + "\n"; }   returnmailboxInformation; } } In the driver class, define three static methods in addition to the main method. a. displayMenu(): which will print the following: Hello! What would you like to do? 1- List Emails in a mailbox 2- Add an email to a mailbox 3- Search for an email in a mailbox by year 4- Sort emails in a mailbox by year 5- Quit b. findMailbox(String client): which loops through the mailboxes array (see main method description below) and return the mailbox object who’s client variable matches the client string parameter. c. addEmailToMailbox(String client): which will take a client name (e.g., gmail) and do the following: i. It will get the mailbox object corresponding to that client by calling findMailbox method ii. It will then prompt the user for the email data then allow the user to enter all of the email data on one line separated by commas: iii. It will then read the data from the line corresponding to each variable inside the Email class iv. Then, it will create a Date object from the month, day, year, and use that in addition to the subject and urgent flag to create an Email object v. Finally it will add the email object to the emails array of the desired mailbox object at the next available location. (Note: the addEmail method of the mailbox object should take care of verifying that we haven’t reached the maximum limit by displaying: You have reached maximum capacity. Upgrade your account In Java

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

public class Date

{

 

privateintyear;

privateintmonth;

privateintday;

 

public Date()

{

 

}

 

public Date(intyear, intmonth, intday)

{

this.year = year;

this.month = month;

this.day = day;

 

}

 

publicint getYear()

{

returnyear;

}

 

publicint getMonth()

{

returnmonth;

}

 

publicint getDay()

{

returnday;

}

 

@Override

public String toString()

{

return"Date [year=" + year + ", month=" + month + ", day=" + day + "]";

}

 

}

public class Date

{

 

privateintyear;

privateintmonth;

privateintday;

 

public Date()

{

 

}

 

public Date(intyear, intmonth, intday)

{

this.year = year;

this.month = month;

this.day = day;

 

}

 

publicint getYear()

{

returnyear;

}

 

publicint getMonth()

{

returnmonth;

}

 

publicint getDay()

{

returnday;

}

 

@Override

public String toString()

{

return"Date [year=" + year + ", month=" + month + ", day=" + day + "]";

}

 

}

public class Date

{

 

privateintyear;

privateintmonth;

privateintday;

 

public Date()

{

 

}

 

public Date(intyear, intmonth, intday)

{

this.year = year;

this.month = month;

this.day = day;

 

}

 

publicint getYear()

{

returnyear;

}

 

publicint getMonth()

{

returnmonth;

}

 

publicint getDay()

{

returnday;

}

 

@Override

public String toString()

{

return"Date [year=" + year + ", month=" + month + ", day=" + day + "]";

}

 

}

public class Mailbox

{

 

private String client;

private Email[] emails;

privateintactualSize;

 

/**

* Default Constructor creates new Email array with maximum of 15 email's sets

* the client to Brad's inbox.

*/

public Mailbox()

{

this.emails = new Email[15];

actualSize = 0;

this.client = "Brad's inbox";

}

 

/**

*

* @param client calls the default consturctor sets client to client set in

* Default Constructor

*/

public Mailbox(String client)

{

 

this();

this.client = client;

 

}

 

/**

*

* @return the email client

*/

public String getClient()

{

returnclient;

}

 

/**

*

* @return emails from emails Array

*/

public Email[] getEmails()

{

returnemails;

}

 

/**

*

* @return how many emails are in inbox

*/

publicint getActualSize()

{

returnactualSize;

}

 

/**

*

* @param email If there is no capacity there is a message to upgrade account If

* not it adds to how many emails till maximum capacity is reached

*/

publicvoid addEmail(Email email)

{

if (this.actualSize >= 15)

{

System.out.println("You have reached maximum capacity. Upgrade your account. ");

} else

{

emails[actualSize] = email;

actualSize++;

}

}

 

publicvoid sortEmailsByDate()

{

 

}

 

/**

*

* @param year email was received

* @return email from year and returns emails that match

*/

public Email findEmail(intyear)

{

for (inti = 0; i < this.actualSize; i++)

{

if (this.emails[i].getDate().getYear() == year)

{

returnthis.emails[i];

}

}

returnnull;

}

 

/**

*

* @return number of urgent emails

*/

publicint countUrgent()

{

intnumberOfEmails = 0;

 

for (inti = 0; i < this.actualSize; i++)

{

if (this.emails[i].isUrgent())

{

numberOfEmails++;

}

}

 

returnnumberOfEmails;

}

 

/**

* toString method that returns the client, the urgent emails, and the number of

* emails

*/

@Override

public String toString()

{

String mailboxInformation = "Mailbox for " + client + " - Urgent emails: " + countUrgent() + " - Emails:\n";

 

for (inti = 0; i < actualSize; i++)

{

mailboxInformation += emails[i].toString() + "\n";

}

 

returnmailboxInformation;

}

}

In the driver class, define three static methods in addition to the main method.
a. displayMenu(): which will print the following:
Hello! What would you like to do?
1- List Emails in a mailbox
2- Add an email to a mailbox
3- Search for an email in a mailbox by year
4- Sort emails in a mailbox by year
5- Quit
b. findMailbox(String client): which loops through the mailboxes array
(see main method description below) and return the mailbox object
who’s client variable matches the client string parameter.
c. addEmailToMailbox(String client): which will take a client name (e.g.,
gmail) and do the following:
i. It will get the mailbox object corresponding to that client by
calling findMailbox method
ii. It will then prompt the user for the email data then allow the
user to enter all of the email data on one line separated by
commas:
iii. It will then read the data from the line corresponding to each
variable inside the Email class
iv. Then, it will create a Date object from the month, day, year, and
use that in addition to the subject and urgent flag to create an
Email object
v. Finally it will add the email object to the emails array of the
desired mailbox object at the next available location. (Note: the
addEmail method of the mailbox object should take care of
verifying that we haven’t reached the maximum limit by
displaying:
You have reached maximum capacity. Upgrade your account
In Java

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education