lundi 11 janvier 2021

How to use delegation design pattern in java and compare to object

i have this following code where i am trying to use delegation design pattern. I have to inner classes QueueComparator implements Comparator interface and RestructuringQueueIterator implements Queue interface. And in the RestructuringQueue class i am trying to create object of those classes to override the methods.

package domain.vehicles;

import domain.Address;
import org.graalvm.compiler.core.common.type.ArithmeticOpTable;

import java.util.*;

 class RestructuringQueue {
     Comparator<Address> comparator = new QueueComparator();
     Queue<Address> queue = new RestructuringQueueIterator();




     private  class QueueComparator implements Comparator<Address> {

          @Override
          public int compare(Address o1, Address o2) {
              return 0;
          }

      }




     private  class RestructuringQueueIterator implements Queue<Address> {



        @Override
        public int size() {
            return 0;
        }

        @Override
        public boolean isEmpty() {
            return false;
        }

        @Override
        public boolean contains(Object o) {
            return false;
        }


        @Override
        public Iterator<Address> iterator() {
            return null;
        }


        @Override
        public Object[] toArray() {
            return new Object[0];
        }

        @Override
        public <T> T[] toArray(T[] a) {
            return null;
        }

        @Override
        public boolean add(Address address) {
            return false;
        }

        @Override
        public boolean remove(Object o) {
            return false;
        }


        @Override
        public boolean containsAll(Collection<?> c) {
            return false;
        }

        @Override
        public boolean addAll(Collection<? extends Address> c) {
            return false;
        }

        @Override
        public boolean removeAll(Collection<?> c) {
            return false;
        }

        @Override
        public boolean retainAll(Collection<?> c) {
            return false;
        }

        @Override
        public void clear() {

        }

        @Override
        public boolean offer(Address address) {
            return false;
        }

        @Override
        public Address remove() {
            return null;
        }

        @Override
        public Address poll() {
            return null;
        }

        @Override
        public Address element() {
            return null;
        }

        @Override
        public Address peek() {
            return null;
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire