Young Coders: Week 3 Problem
EDIT: Just one extra Candy Challenge problem this week! The full Candy Challenge = the following problem + two Candy Challenges from previous classes. For those of you who have finished all the previous Candy Challenges, pick two problems from Week 2's 3,4, and 5, and try to solve them iteratively (with loops), instead of recursively. Write a toString() method for our Queue class that prints out its elements. For example, public static void main(String[] args) { Queue animals = new Queue(); animals.enq("Tiger"); animals.enq("Pig"); animals.enq("Zebra"); System.out.println(animals); } will give us {"Tiger", "Pig", "Zebra"} , not the hashCode() we have now (something like Queue@56ee20fe). (An example: Look at the outline of a toString() method we wrote in the Pet class.)