top of page

Witter - Java Assignment

Updated: Oct 16, 2021

Hi, Hope you are doing well. Today , I share you a good project idea on Java.


Problem Statement

Define a class called Weet to store microblog text entries (weets). The class should have private instance variables to store the poster’s emoticon, full name, username, verification status, text of the entry, and the date and time of the entry. Use the provided WitterDate class to handle times and dates. Please carefully analyze the WitterDate class and make sure you understand it. (Don’t change the WitterDate class.)


Each text entry may contain a maximum of 140 characters. If a user enters more than 140 characters, truncate the text to 137 characters and add on an ellipsis (“...”).

As with other competing services, Witter verifies users. If a user is verified, a checkmark ✓

appears in between their full name and their username. Also, the username should be prefaced by an @ symbol.


Unfortunately, as in real life, plagiarism is an issue on Witter. You should have a method to

compare an original weet with a subsequent weet. If the subsequent weet has the same text and is weeted on the same date, this is considered plagiarism. If plagiarism is detected, the text of the latter jeet should be replaced with [Plagiarism detected. Text removed.]


Your program should also keep track of valid weets delivered and plagiarized weets.


Demo Program

The following code (also available here) presents a demo program that uses the class:


WitterDate class

public class WitterDate {

    private String month;
    private int day;
    private int year; // a four digit number
    private int hour;
    private int minute;
    private boolean am;


    // no argument constructor
    public WitterDate() {
        month = "January";
        day = 1;
        year = 2017;
        hour = 12;
        minute = 0;
        am = true;
    }

    public WitterDate(String aMonth, int aDay, int aYear, int aHour, int aMinute, boolean aAm) {
        setDate(aMonth, aDay, aYear, aHour, aMinute, aAm); // invoking setDate() method
    }

    public WitterDate(int aDay, int aHour, boolean aAm) {
        setDate(aDay, aHour, aAm);
    }

    // copy constructor
    public WitterDate(WitterDate wDate) {

        // not a real date
        if (wDate == null) {
            System.out.println("Fatal error.");
            System.exit(-1);
        }

        month = wDate.month;
        day = wDate.day;
        year = wDate.year;
        hour = wDate.hour;
        minute = wDate.minute;
        am = wDate.am;
    }

    public void setDate(String aMonth, int aDay, int aYear, int aHour, int aMinute, boolean aAm) {
        month = aMonth;
        day = aDay;
        year = aYear;
        hour = aHour;
        minute = aMinute;
        am = aAm;
    }

    public void setDate(int aDay, int aHour, boolean aAm) {
        setDate("September", aDay, 2017, aHour, 0, aAm);
    }

    public int getDay() {
        return day;
    }

    public int getYear() {
        return year;
    }

    public String getMonth() {
        return month;
    }

    @Override
    public String toString() {
        String abbrevMonth = month.substring(0,3);

        String amString = "";

        if (am) {
            amString = "AM";
        } else {
            amString = "PM";
        }

        String result = String.format("%d:%02d %s - %s %d, %d", hour, minute, amString, abbrevMonth, day, year);

        return result;
    }
    @Override
    public boolean equals(Object o) {
        if (o instanceof WitterDate) {
            WitterDate other = (WitterDate) o;
            return month.equals(other.month) && day == other.day && year == other.year;
        } else {
            return false;
        }
    }
}

WitterDemo class:

public class WitterDemo {
public static void main(String[] args) {
Weet shakeWeet = new Weet("(7:^]", "William Shakespeare",

"shakespeare", true);
Weet fakeShakeWeet = new Weet("o_O", "Wilhelm Shakespeare",
"fakeShake", false);
Weet jadenWeet = new Weet(":-|", "Jaden Smith", "officialJaden", true);
System.out.println("\n===== Welcome to Witter! =====\n");
shakeWeet.setDate(new WitterDate("November", 1, 1611, 3, 37, true));
String shakeText = "Our revels now are ended. These our actors,\n"
+ "As I foretold you, were all spirits and\n"
+ "Are melted into air, into thin air:\n"
+ "And, like the baseless fabric of this vision,\n"
+ "The cloud-capp'd towers, the gorgeous palaces,\n"
+ "The solemn temples, the great globe itself,\n"
+ "Ye, all which it inherit, shall dissolve...";
shakeWeet.setWeetText(shakeText);
fakeShakeWeet.setDate(new WitterDate("November", 1, 1611, 6, 42, false));
fakeShakeWeet.setWeetText(shakeText);
jadenWeet.setDate(new WitterDate("May", 1, 2013, 6, 23, false));
jadenWeet.setWeetText("How Can Mirrors Be Real If Our Eyes Aren't Real");
fakeShakeWeet.plagiarismCheck(shakeWeet);
jadenWeet.plagiarismCheck(shakeWeet);
System.out.println(shakeWeet);
System.out.println(fakeShakeWeet);
System.out.println(jadenWeet);
System.out.println("===== End of Witter feed =====\n");
System.out.printf("Witter has shipped a total of %d weet(s)"
+ " and detected %d fake weet(s).%n",
Weet.getNumWeets(), Weet.getNumFakeWeets());

}
}


Sample Run of the Demo Program

The following presents a sample result of the demo program. Read the result very carefully so you can identify the operations of the program.

Output

===== Welcome to Witter! =====
(7:^] William Shakespeare ✓ @shakespeare
Our revels now are ended. These our actors,
As I foretold you, were all spirits and
Are melted into air, into thin air:
And, like the bas...
3:37 AM - Nov 1, 1611
o_O Wilhelm Shakespeare @fakeShake
[Plagiarism detected. Text removed.]
6:42 PM - Nov 1, 1611
:-| Jaden Smith ✓ @officialJaden
How Can Mirrors Be Real If Our Eyes Aren't Real
6:23 PM - May 1, 2013
===== End of Witter feed =====
Witter has shipped a total of 2 weet(s) and detected 1 fake weet(s).

If you need solution of these questions or looking any other Java assignment help then you can contact with us and get instant help.



bottom of page