import java.util.LinkedList;.

Added on - 18 Sep 2019

  • 1

    pages

  • 274

    words

  • 95

    views

  • 0

    downloads

Showing pages 1 to 1 of 1 pages
import java.util.LinkedList;public class Base_A11Q2 {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());}}
desklib-logo
You’re reading a preview
card-image

To View Complete Document

Become a Desklib Library Member.
Subscribe to our plans

Download This Document