Program Questions:
Develop a Java package with simple Stack and Queue classes. Use JavaDoc
comments for documentation.
ALGORITHM:
step 1:Define package pack1 with the keyword package.
step 2:Define the class ArrayQueue with the integers.
step 3:Using a 1 argument constructor,the max size of the queue is assigned.
step 4:Define the method insert() with an item in object type as argument to insert an item.
step 5:Define the method remove() to delete an item from the queue.
step 6:Define the method peek() to return the item which is at the top of stack.
Step 7:Define the method displayAll() to display the contents of the queue.
step 8:Terminate the class .Create an another package pack1 using the keyword package.
step 9:Define the class ArrayStack with an object array'a' and an integer top as datamembers.
step 10:Using a one argument constructor define the size of the array.
step 11:Define the method push() to push an item into the stack.
step 12:Define the method pop() to delete an item from the stack.
step 13:Define the method peek() to return the item at the top of the stack.
step 14:Terminate the class.
step 15:Import the package pack1,define the class StackQueueDemo.
step 16:Define the main() in the class.
Create objects for the classes ArrayStack and ArrayQueue and access the methods using the objects.
step 17:Display the result.
step 18: terminte the main() and terminate the class.
Develop a Java package with simple Stack and Queue classes. Use JavaDoc
comments for documentation.
ALGORITHM:
step 1:Define package pack1 with the keyword package.
step 2:Define the class ArrayQueue with the integers.
step 3:Using a 1 argument constructor,the max size of the queue is assigned.
step 4:Define the method insert() with an item in object type as argument to insert an item.
step 5:Define the method remove() to delete an item from the queue.
step 6:Define the method peek() to return the item which is at the top of stack.
Step 7:Define the method displayAll() to display the contents of the queue.
step 8:Terminate the class .Create an another package pack1 using the keyword package.
step 9:Define the class ArrayStack with an object array'a' and an integer top as datamembers.
step 10:Using a one argument constructor define the size of the array.
step 11:Define the method push() to push an item into the stack.
step 12:Define the method pop() to delete an item from the stack.
step 13:Define the method peek() to return the item at the top of the stack.
step 14:Terminate the class.
step 15:Import the package pack1,define the class StackQueueDemo.
step 16:Define the main() in the class.
Create objects for the classes ArrayStack and ArrayQueue and access the methods using the objects.
step 17:Display the result.
step 18: terminte the main() and terminate the class.
No comments:
Post a Comment