Package ic211

Class Tweet


  • public class Tweet
    extends Object
    This class represents a single Tweet
    • Constructor Detail

      • Tweet

        public Tweet​(String text,
                     String userName,
                     String date)
        Constructs a Tweet object.
        Parameters:
        text - The text of the message
        userName - the Twitter user name of the poster
        date - the date in YYYY-MM-DD format, e.g. "2014-12-25"
    • Method Detail

      • read

        public static Tweet read​(Scanner sc)
        Reads data from a Scanner and creates & returns a Tweet from it. The expected format is a single line wth three tab-delimited fields, the first of which is the Tweet text, the second the Twitter user name, the third the date in YYYY-MM-DD format. For example:
        IC211 was awesome today ... as usual.   csitmid   2015-02-13
        Parameters:
        sc - The scanner that input will be read from.
        Returns:
        null if the necessary Tweet data cannot be read, a newly constructeed Tweet otherwise.
      • toString

        public String toString()
        Returns a String representation of a Tweet in message-tab-user-tab-date format. Note that the date is in YYYY-MM-DD format.
        Overrides:
        toString in class Object
        Returns:
        a String representation of a Tweet in message-tab-user-tab-date format.
      • getText

        public String getText()
        Get the message text of the Tweet.
        Returns:
        the message text of the Tweet.
      • getUserName

        public String getUserName()
        Get the user name of the poster.
        Returns:
        the Twitter user name of the poster.
      • getDate

        public String getDate()
        Get the date of the post in YYYY-MM-DD format.
        Returns:
        the date of the Twitter post in YYY-MM-DD format.