2. Develop a class called AO12Email based on the following specification: StuPreEmail - idGen : int =
Question:
2. Develop a class called AO12Email based on the following specification:
StuPreEmail |
- idGen : int = 1000 - id : int - from : StuPreContact - to : StuPreContact - subject : String - timeStamp : LocalDateTime |
+ StuPreEmail() + StuPreEmail(from : StuPreContact, to : StuPreContact, subject : String) + StuPreEmail(from : StuPreContact, to : StuPreContact, subject : String, time : LocalDateTime) + getFrom() : StuPreContact + getTo() : StuPreContact + getSubject() : String + getTimeStamp() : LocalDateTime + setFrom(from : StuPreContact) : void + setTo(to : StuPreContact) : void + setSubject(subject : String) : void + toString() : String |
- The static memberidGen is used to generate a unique id for each new email object. Its current value should be used when creating a new email object and then incremented (to prepare for the next object). Hint: it needs to be used and updated in each constructor.
- Default constructor: constructs an email object with a unique id based onidGen. Use null value for the remaining data members.
- The three-parameter constructor: constructs an email object with a unique id based onidGen, and the specified from, to, and subject fields. The timestamp field will be set to the current local time:timeStamp = LocalDateTime.now();
- The four-parameter constructor: constructs an email object with a unique id based onidGen and the specified from, to, subject, and time fields
- getXXX() and setXXX() methods follow the general convention of such methods.
- toString(): returns a string representation of the calling Email object in this format:
Subject: subject-str
From: from-contact-in-a-string
To: to-contact-in-a-string
Time: timestamp-in-a-string
- Be sure to use thetoString() method of theStuPreContact class.
- Use this segment of code to convert thetimeStamp data member (aLocalDateTimeobject) to a string: // format: Three-letter-month-name, dd, yyyy, hh:mm AM-or-PM
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("LLL dd, yyyy, hh:mm a");String timeStr = timeStamp.format(formatter);
- You will use two new classes in this exercise:LocalDateTime andDateTimeFormatter. import java.time.LocalDateTime; import java.time.format.DateTimeFormatter;
- Set up a simplemain()within this Email class to include the following:
1). Add aContact object with your name and with email a..w@e.com.
2). Add a 2ndContact object with the information of a friend of yours.
3). Add anEmail object using the three-parameter constructor: from you to your friend with some subject string.
4). Add a 2ndEmail object using the four-parameter constructor: from your friend to you with a different subject. The time argument should beyourFirstEmailVar.getTimeStamp().plusHours(1) which means 1 hour after the first email message. plusHours() is a method of LocalDateTime.
5). Print out the 1st email object.
6). Print out the 2nd email object.
Systems analysis and design in a changing world
ISBN: 978-1423902287
5th edition
Authors: John W. Satzinger, Robert B. Jackson, Stephen D. Burd