Databird: A Java Introduction
Due on September 10th at 11:59 PM.
This is an individual assignment. You are to complete this assignment on your own, although you may discuss the lab concepts with your classmates. Remember the Academic Integrity Policy: do not show your work to anyone outside of the course staff and do not look at anyone else’s work for this lab. If you need help, please post on the Piazza forum or contact the instructor. Note that no exception is made for your group members; collaboration with your group members is a violation of the Academic Integrity Policy as much as collaboration with other members of the class. If you have any doubts about what is okay and what is not, it’s much safer to ask than to risk violating the Academic Integrity Policy.
Overview
Your task in this assignment is to become familiar with the Java language and IntelliJ, the Java IDE we will be using for this course. You will accomplish this by writing a small application to store and search a database of Twitter posts.
Starting Materials
To begin your assignment, clone the appropriate Git repository from the Swarthmore GitHub server:
git clone git@github.swarthmore.edu:cs71-f17/databird-<username>.git
Make sure to replace <username>
above with your Swarthmore College username.
Your initial repository contains three files:
- A data file,
twitter-data.txt
, which contains the Twitter posts you will be using. - A Java source file
Post.java
, representing a single twitter post. - A Java source file
Databird.java
, representing the interface to your Twitter database.
The Java source files are stored in an appropriate directory structure corresponding to their package.
Configuring Your IDE
You are required to use an IDE for development in this course. In this assignment, we will use IntelliJ IDEA Community Edition, an open source development environment which primarily targets Java but supports a variety of plugins and features.
To protect your disk quota and avoid unnecessary network activity, IntelliJ has been installed in /local
on all of the CS network machines. You can run IntelliJ using the following command:
me@computer:~$ /local/intellij/bin/idea.sh
If you want to create a link to this file so you can launch it more easily in the future, you can create a bin
directory in your home directory and it will be added to your PATH
of available commands the next time you log in. For instance, the commands
me@computer:~$ mkdir -p ~/bin
me@computer:~$ ln -s /local/intellij/bin/idea.sh ~/bin/ij
will create a symlink ij
. The next time you log in, you can just run ij
from the prompt to start IntelliJ. (If you’ve already created your bin
directory in the past, ij
should work immediately.)
Creating a Project
After proceeding through the basic IDE configuration dialogs, IntelliJ will present the following welcome dialog:
To add your repository as a project to the IDE, follow these steps:
- Select “Import Project”
- Choose the directory where you’ve cloned the assignment
- Proceed through the various dialogs to create your project; default settings should suffice.
Once you’ve successfully created the project, your IDE window should look like this:
Completing the Assignment
Your task is to write a small application to load and search the provided Twitter posts. This data is provided as a text file in which each post consists of four lines:
- The username of the user who created the post
- The screenname of the user who created the post
- The time of the post (as a string)
- The content of the post (on a single line)
Your application should read the contents of the twitter-data.txt
file at startup and present the user with a text-based interface with the following options:
- Given a screenname, list all posts by the user with that screenname.
- Given a screenname, list the 10 most recent posts by that user.
- Given a string, list all posts by containing that string in the body.
- Given a string, list the 10 most recent posts containing that string in the body.
- Exit the application.
The listings above must appear in chronological order (oldest first). This can be achieved by sorting the list based upon the string representing the post’s time. After satisfying each request, your application should prompt for another.
Your application must also meet the following requirements:
- You may put the
main
method for your application in whichever class you like. However, that class should be in an appropriate package (such asedu.swarthmore.cs.username.cs71.databird
). - You must put a
README.md
file in the root of your Git repository identifying the main class of your application. - Your application must include a class which correctly implements the
Databird
interface. Be sure to read the documentation of those methods for their complexity requirements.
Submitting the Assignment
Assignments in this course will be submitted via the Swarthmore GitHub server. Make sure to commit and push all of your work (including e.g. the .iml
project file that IntelliJ creates). The contents of your repository at the due date will determine your grade. As always, please contact your instructor if you have any difficulties.