Code Monkey home page Code Monkey logo

Felix Gao's Projects

delayed-queue icon delayed-queue

A queue is a data structure where the element removed is always the oldest element (the one which has been waiting the longest) out of the remaining elements, ie. the one which was added the least recently. See: Queue (abstract data type) - Wikipedia. The two main operations are enqueue(E) which adds an element and dequeue() which removes an element. A DelayedQueue works like a normal queue except has a restriction ('delay condition') that prohibits elements from being removed until a certain number of enqueue operations have occurred. Once the required number of enqueue operations occur, any number of elements may be removed, however the moment another element is added, the delay condition comes back into force. Your task is to create a class called MyQueue that implements the generic DelayedQueue interface according to the specification written in the docstrings for each method. Your class should be able to be instantiated with DelayedQueue<...> s = new MyQueue<...>(7); where the ... can be replaced by any object, and the int parameter for the constructor represents the max delay value (ie. number of enqueue operations that must occur before dequeue operations can start to occur). If the max delay value is changed, the change does not take effect until the next time the delay is reset to the maximum (ie. when enqueue occurs after a sequence of dequeue operations).

delayed-stack icon delayed-stack

A DelayedStack works like a normal stack except has a restriction ('delay condition') that prohibits elements from being removed until a certain number of push operations have occurred.

flower-pot icon flower-pot

Flower Pot Create the Flower and Pot classes according to the following specification detailed in the UML diagram below and Javadocs: Updates (and responses to common Ed questions): If the pot is empty (or none are alive), averageAge and averageHeight should return -1 maxAge is the maximum age of the flower, if the age goes beyond this, it dies For clarity, tan^-1 means the inverse tan function (arctan) not 1/tan(). Note that searches for null values in species and colour crierion should work and be able to find flowers in the pot with null values as those attributes Most Pot tests require the use of insert(), water() and rearrange(), so make sure these methods are working first. combine() and view() should not include flowers with null colour in the result. view() method is case insensitive for the colour string If null is passed as input to the Pot insert() method, return false. (cannot add null) For the replace() method, if both are null, return 0. The first hidden testcase is testing the order of the colours in the view() method output is in alphabetical order. See the assignment helpful notes. You need to add the entries into an ArrayList and then sort using a Comparator, or use a TreeMap instead of HashMap. The TreeMap is automatically sorted by key order, unlike HashMap which is unordered. For replace() and filter(), ensure you don't create a situation where a Flower object is present in multiple pots, or more than once in the same pot. Testcase file has been released (hidden tests removed):

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.