logo

import java.util.LinkedList;.

1 Pages274 Words248 Views
   

Added on  2019-09-18

import java.util.LinkedList;.

   Added on 2019-09-18

ShareRelated Documents
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());}}
import java.util.LinkedList;._1

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Java Programming | Assignment
|9
|834
|20