Your company has a server and there are 500 PC stations whose filesystem resides on it, numbered 1 through 500 inclusive. Every 10 minutes the system appends to a log file the PC numbers and user name of the person currently logged on, one PC number and username per line of text. (Not all stations are in use at every moment). A fragment of the log file looks like this:
... ...... 9 ALTEREGO 12 ROOT 433 JOECOHEN 433 USERMGR 12 WHEEL 433 JOECOHEN 354 ROOT ... ...
This log file shows JOECOHEN was on PC station 433 twice but USERMGR was on that station at an intervening time. It also shows that ROOT was on station 12 at one time and station 354 later on. Your job is to write a program in Java that meets the following specifications:
1. The program first reads a log file into memory, storing the input data as it encounters it. Assume IO redirection when your program is invoked, so it must be read from System.in rather than by actually opening a named text file. User names are ASCII (plain text) strings with no embedded whitespace and a maximum length of 40 characters.
2. After all the data has been read your program should print data about PC station usage: a header line and then one line of output for each PC showing the PC station number, the most common user of that station (in the event of a tie, choose one user), and a count of how many times that user was on that PC station. Here is sample output:
Line, Most Common User, Count 1, OPERATOR, 174983 2, HANNIBAL, 432 3, -NONE-, 0 4, SYSMGR, 945 ., ..., ...
3. Program design: The attached code shows class SinglyLinkedList.java, for your use to hold all the information about one PC. Do not change this class, but instead, wrap it in another class LineUsageData (i.e. LineUsageData HAS-A SinglyLinkedList.) Although normally we would use a JDK LinkedList or other JDK container for this, for the qualifier the essential thing is to check that you know how to work with any reasonable Java classes. Design and implement a class Usage to hold a (username, count) pair, and a class TermReport for the top-level code. Usage can be a nested class of TermReport, or a top-level class. An object of type LineUsageData holds all the data for one particular PC station, and has methods addObservation(String username) and Usage findMaxUsage(). TermReport.java should be decomposed into methods; including a main(). Each method should be commented (a comment above the method to describe it and comments for internal statements as needed).
Find SinglyLinkedList.java in the hw0 folder here: https://github.com/ieee8023/cs310-summer2015
Turn in the code for classes Usage, TermReport, and LineUsageData. Your program should be complete and compile. Note: Since the purpose of this exercise is to determine whether you are prepared for this course you should not discuss the material with anyone else. (Later in the term we will encourage these discussions.)
Your code must compile with the following command:
javac -cp . Usage.java TermReport.java LineUsageData.java SinglyLinkedList.java
and run with the following command (Make your own users.log):
java -cp . TermReport < users.log
Due: 5pm on 5/28 in the folder cs310/hw0 on users.cs.umb.edu.
3 points: Reads input and stores in Usage and LineUsageData objects
3 points: Correctly uses the SinglyLinkedList of Usage objects and no other implementation of a linked list
2 points: Correctly prints out totals given input file
2 points: memo.txt containing a discussion about the assignment, easy to grade, files and folders named correctly