Write program for queue of cards, JAVA Programming

Assignment Help:

A Queue of Cards

You are going to parallel the development done in the lesson on inheritance where we constructed some base classes, StackNode and Stack, and derived  FloatNode and FloatStack from them.  You can work best by referring to those modules all through the development of your program.  These are the differences between what we did in the lesson and what you will do for your assignment.

  1. Instead of a Stack data structure, you will create a Queue data structure.  A Stack is last-in-first-out (LIFO).  A Queue is first-in-first-out (FIFO).
  2. Instead of deriving a FloatNode from the basic Node class, you will derive a CardNode from NodeCardNode will use the Card class of Week 1.

Here are the details:

Base Class Node

You can use the same class for a base class that was used in the modules.  However, I want you to give this class a different name.  Call it Node (not QueueNode or StackNode, just Node).

Base Class Queue

Next, do almost the same thing as we did with the Stack class, except make sure that this class works like a Queue, not a Stack.  That means

  • We add items to the Queue using Add() not Push()Push() does not appear in our Queue class.
  • We retrieve items from the Queue using Remove() not Pop()Pop() does not appear in our Queue class.
  • Remove() removes and returns the oldest item in the Queue.  This is different from Pop() which removed and returned the youngest item in the Queue.
  • Provide a ShowQueue() method that displays all the items in the Queue from oldest to youngest.
  • Instead of one Node pointer member, top, you'll need two Node pointer members, and neither should be called top (since top is not meaningful in a Queue).  Examples are head/tail, front/back, oldest/youngest, etc.  Select two names and use them accordingly.

Once you have written these two classes, write a simple test main() just like I did in the modules - show a run that displays some (generic node)s.  Test the ShowQueue() method and also build a simple loop in your main() to remove and display nodes as they are removed.   Compare the output of these two techniques -- they should be identical.  You will not hand this in.  It is just for your use in developing the full program.

Add() and Remove() will be slightly more complicated than Push() and Pop() because you have two pointers, front and back (or head and tail, or whatever you call them) to manage.  This may take some time and debugging.  Test it carefully.  Even after you get it to work, you may find that it still needs debugging later, since your "(generic node)" screen results won't tell you if things are coming off in the correct order.  You won't know that until you have real data in your Nodes.  That's the next part.


Related Discussions:- Write program for queue of cards

Luminous Jewels - The Polishing Game, Byteland county is very famous for lu...

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

write program a, How do I write a program a bout Rotor cipher

How do I write a program a bout Rotor cipher?

Compiler Design - Limit the loops, Problem : Compiler Design - Limit the lo...

Problem : Compiler Design - Limit the loops Rajni is a newbie to the programming and while learning the programming language he came to know the following rules: ???• Each

Write a cgi program, Write a CGI program in R, accessible through the class...

Write a CGI program in R, accessible through the class web server, that performs an analysis or creates a graph. You can provide a separate HTML page that displays the initial form

Support for web and enterprise web applications, Support for Web and Enterp...

Support for Web and Enterprise Web Applications Java offers an extensive support for the development of web and enterprise applications Servlets, JSP, Applets, RMI, JDBC, EJBs

Application for software tracking system, Talent agencies like ICM, CAA and...

Talent agencies like ICM, CAA and Paradigm represent writers, directors and actors (among other talent).  These agencies take in hundreds of millions of dollars a year collecting 1

Prepare a java program, Using Java, write the class Time which consists of ...

Using Java, write the class Time which consists of the following: (a) three private integer data members (hours, minutes and seconds). (b) a constructor to initialise the dat

Program to change base system, Write a program called BaseConverter that pr...

Write a program called BaseConverter that prompts (asks) the user for a base 10 number and another number, between 2 and 10 inclusive. This second number is the base to which to co

Send input to different command prompt, I am supposed to call an external a...

I am supposed to call an external application (which is command-line based) and send input to the application from java. I created a batch file to call the application. It successf

Array, public class Tester { static void test(int[] a) { int[] b = new in...

public class Tester { static void test(int[] a) { int[] b = new int[2]; a = b; System.out.print(b.length); System.out.print(a.length); } public static void main(String[] arg

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd