Create a message buffer that manages and incoming phone call
Create a \"message buffer\" that manages and incoming phone calls and messages in an answering machine. Implement it using the LinkedList API. (Do not import any other packages.) . In particular, see the MessageBufferADT interface which contains a description of the methods required in the message buffer. Create a Message class that implements Comparable and contains the name of the caller, the date they called, the time, and the length of the call in seconds (as an integer). Make getters and a compareTo method that passes in another Message and compares the length of the messages. This method should compare the length of the two messages and return -1 if the first message is shorter than the second message, 0 if the length of the messages is equal, and 1 if the first message is longer than the second message. All phone messages are added into the message buffer. The highest priority message in a message buffer is the message with the shortest length. When removing messages, your message buffer should return the highest priority message. Messages should be removed from the buffer when the phone call is returned. The attached file already contains a test main that creates three Message objects, adds them to a message buffer, and removes/displays them one by one.
import java.util.LinkedList;
public class Base {
static class Message implements Comparable<Message> {
//TODO: complete class
}
static interface MessageBufferADT {
/**
* Adds one message to the buffer.
* @param m the message to be added to the buffer
*/
public void add(Message m);
/**
* Removes and returns the highest priority message in the buffer.
* @return the highest priority message in the buffer
*/
public Message remove();
/**
* Returns true if this buffer contains no elements.
* @return true if this buffer is empty
*/
public boolean isEmpty();
/**
* Returns the number of elements in this buffer.
* @return the integer representation of the size of the buffer
*/
public int size();
}
static class MessageBuffer implements MessageBufferADT {
//TODO: complete class
}
public static void main(String[] args) {
MessageBuffer messageBuffer = new MessageBuffer();
Message m3 = new Message(\"Bill\", \"08/07/2016\", \"8:08AM\", 160);
Message m2 = new Message(\"Joseph\", \"09/05/2016\", \"2:35PM\", 120);
Message m1 = new Message(\"Steve\", \"09/20/2016\", \"11:45PM\", 60);
messageBuffer.add(m1);
messageBuffer.add(m2);
messageBuffer.add(m3);
System.out.println(messageBuffer.remove());
System.out.println(messageBuffer.remove());
System.out.println(messageBuffer.remove());
}
}
Solution
The distinction between 3NF and BCNF is refined.
3NF
Definition
A relation is in 3NF if it\'s in 2NF and no non-prime attribute transitively depends on the first key. In different words, a relation R is in 3NF if for every practical dependency X A in R a minimum of one in every of the subsequent conditions area unit met:
X may be a key or superkey in R
A may be a prime attribute in R
Example
Given the subsequent relation:
EMP_DEPT(firstName, employeeNumber, dateOfBirth, address, departmentNumber, departmentName)
An worker will solely add one department and every department has several staff.
The candidate secret\'s employeeNumber.
Consider the subsequent practical dependencies:
employeeNumber firstName, dateOfBirth, address, departmentNumber
departmentNumber departmentName
Given the definition on top of it\'s attainable to conclude that the relation EMP_DEPT isn\'t in 3NF as a result of the second practical dependency doesn\'t meet any of the two conditions of the 3NF:
departmentNumber isn\'t a key or superkey in EMP_DEPT
departmentName isn\'t a main attribute in EMP_DEPT
BCNF
Definition
A relation R is in BCNF if it\'s in 3NF and for every practical dependency X A in R, X may be a key or superkey in R. In different words, the sole distinction between 3NF and BCNF is that in BCNF it\'s not gift the second condition of the 3NF. This makes BCNF stricter than 3NF as any relation that\'s in BCNF are going to be in 3NF however not essentially each relation that\'s in 3NF are going to be in BCNF.
Example
Given the subsequent relation:
STUDENT_COURSE(studentNumber, socialSecurityNumber, courseNumber)
A student will assist {to several|to several} courses and in a very course there will be many students.
The candidate keys are:
socialSecurityNumber, courseNumber
studentNumber, courseNumber
Consider the subsequent practical dependencies:
studentNumber socialSecurityNumber
socialSecurityNumber studentNumber
Given the definitioin on top of it\'s attainable to conclude that STUDENT_COURSE isn\'t in BCNF as a minimum of studentNumber isn\'t a key or superkey in STUDENT_COURSE.

