Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Logger objects are often used to keep track of what happened in an application. They usually support add, reset, and some statistical functions to query

Logger objects are often used to keep track of what happened in an application. They usually support add, reset, and some statistical functions to query what happened. Update and remove operations are not supported by loggers. In this assignment, you will need to program an EventLogger class, which needs to implement the LoggerInterface. The methods that need implementation are given in the LoggerInterface.java. Use the comments from the interface to figure out the requirements. Each entry in the logger has three pieces of information: description: String category: int timestamp: long The timestamp of the events that are added to the logger should be non-decreasing. When adding an event with a wrong timestamp, the event should NOT be added to the logger. Instead, the add method should print(use System.out.println) Wrong clock, and return -1. The first three test cases will test the correctness of your implementation of EventLogger.java The next task is to implement a CheckInOut class that keeps track of the check-in/out of employees. The class should try to reuse the methods from EventLogger class through inheritance, while implements a method from TimesheetInterface, which consists of a single abstract method void displayAccumulatedTime(). The method displays the total time for each employee. The employees should be displayed based on the original order in the check-in/out log, and each employee should appear exactly one time in the display. In CheckInOut class, you may associate special meanings to the parameters of the add method inherited from the EventLogger class: description name of employee category 1 for check-in 2 for check-out timestamp check-in or checkout time To compute the total time, add the difference between the check-in and the closest check-out. If there is a check-in without check-out, ignore the check-in entry. You may assume that all check-out entries have preceding check-ins. Test cases 4, 5 and 6 are for this task. Given codes : public interface TimesheetInterface { // display the accumulated time for each void displayAccumulatedTime(); } Given: public interface LoggerInterface { // add an event with its category and timestamp // returns the seq number of the event in the logger // the first added event's sequence number is 1(not 0) int add(String desc, int category, long time); // reset the logger to empty void reset(); // count the number of events in the logger based on desc int count(String desc); // count the number of events that are in a category and have a // matching desc int count(String desc, int category); // find the timestamp of the first specified by the event long first(String desc); } tester class Example: public class EventLoggerTest { public static void main(String[] args) { EventLogger logger = new EventLogger(); System.out.println(logger.add("Jack", 1, 3)); System.out.println(logger.add("Alice", 1, 4)); System.out.println(logger.add("Lindsey", 1, 7)); System.out.println(logger.add("John", 1, 7)); System.out.println(logger.add("Mark", 1, 6)); System.out.println(logger.add("Alice", 2, 10)); System.out.println(logger.add("John", 2, 13)); } } Output Example: 1 2 3 4 Wrong clock -1 5 6

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

what is a peer Group? Importance?

Answered: 1 week ago

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago