Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Programming: Define a class called TweetEntry that could be used to store a

ID: 3668099 • Letter: J

Question

Java Programming:

Define a class called TweetEntry that could be used to store a tweet of your choice. The calss should have instance variables to store the twitter account holder's first name, last name, username, text of the tweet, and the date of the tweet using java Date class. Add a constructor that allows the user of the class to set all instance variables. Also add a method, displayAccountlnfo, that outputs all of the instance variables, and another method called weet that retuns the first 140 characters of the tweet text. If the tweet text exceeds the 140 charaters truncate the all the characters over 140 and display Test your class by creating another class and call it TweetEntryDriver that will have the main method. Here is an example run of your program: 1. Whern displayAccountlnfo method is called Profile Summary: First Name zak Last Name: Baani Usernmae: #zb Date started: Tue Feb 02 08:27:10 CST 2016 2. When the showM weet method is called zak B zb #zb Twitter limits Tweet length to 140 characters making the definition of a character and how they are counted central to any Twitter appli

Explanation / Answer

import java.util.Date;

/**
* @author Srinivas Palli
*
*/
public class TweetEntry {

   String firstName, lastName, userName, text;
   Date tweetDate;

   public TweetEntry() {
       // TODO Auto-generated constructor stub
   }

   /**
   * @param firstName
   * @param lastName
   * @param userName
   * @param text
   * @param tweetDate
   */
   public TweetEntry(String firstName, String lastName, String userName,
           String text, Date tweetDate) {
       super();
       this.firstName = firstName;
       this.lastName = lastName;
       this.userName = userName;
       this.text = text;
       this.tweetDate = tweetDate;
   }

   /**
   * @return the firstName
   */
   public String getFirstName() {
       return firstName;
   }

   /**
   * @return the lastName
   */
   public String getLastName() {
       return lastName;
   }

   /**
   * @return the userName
   */
   public String getUserName() {
       return userName;
   }

   /**
   * @return the text
   */
   public String getText() {
       return text;
   }

   /**
   * @return the tweetDate
   */
   public Date getTweetDate() {
       return tweetDate;
   }

   /**
   * @param firstName
   * the firstName to set
   */
   public void setFirstName(String firstName) {
       this.firstName = firstName;
   }

   /**
   * @param lastName
   * the lastName to set
   */
   public void setLastName(String lastName) {
       this.lastName = lastName;
   }

   /**
   * @param userName
   * the userName to set
   */
   public void setUserName(String userName) {
       this.userName = userName;
   }

   /**
   * @param text
   * the text to set
   */
   public void setText(String text) {
       this.text = text;
   }

   /**
   * @param tweetDate
   * the tweetDate to set
   */
   public void setTweetDate(Date tweetDate) {
       this.tweetDate = tweetDate;
   }

   /**
   * method to print all members
   */
   public void displayAccountInfo() {

       System.out.println("Profile Summary:");
       System.out.println(" First Name:" + firstName);
       System.out.println(" Last Name:" + lastName);
       System.out.println(" User Name:" + userName);
       System.out.println(" Date Started:" + tweetDate);

   }

   /**
   * Method to show the tweet text
   */
   public void showMyTweet() {
       String tweetText = getText();
       if (tweetText.length() > 140) {
           tweetText = tweetText.substring(0, 140);
       }
       System.out.println(tweetText);
   }

   /**
   * @param args
   */
   public static void main(String[] args) {

       try {
           TweetEntry tweetEntry = new TweetEntry("zak", "Baani", "#zb",
                   "Hai this is srinvias how are you", new Date());
           tweetEntry.displayAccountInfo();
           tweetEntry.showMyTweet();

       } catch (Exception e) {
           // TODO: handle exception
       }
   }

}

OUTPUT:

Profile Summary:
   First Name:zak
   Last Name:Baani
   User Name:#zb
   Date Started:Mon Feb 15 12:48:37 IST 2016
Hai this is srinvias how are you

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote