Question: Your task is to complete the missing code of AccountStack.java // array implementation of stack public class AccountStack { private AccountNode[] mystack; private int size;

 Your task is to complete the missing code of AccountStack.java //

Your task is to complete the missing code of AccountStack.java

// array implementation of stack

public class AccountStack { private AccountNode[] mystack; private int size; private int current_index;

public AccountStack(int size) { // your code goes here: // constructor } private boolean isFull() { if(current_index==size) return true; else return false; } private boolean isEmpty() { if(current_index==0) return true; else return false; } public boolean push(AccountNode n) { // your code goes here: // push AccountNode n to the top of stack and return true // if stack is full, do nothing and return false } public AccountNode pop() { // your code goes here: // return the data item at the top of stack // if stack is empty, retun null } }

public class stackTest { public static void main(String[] args) { AccountStack instac = new AccountStack(50);

AccountNode n1 = new AccountNode(2002, "Janet Smith", 100.99); AccountNode n2 = new AccountNode(1001, "Alex Bush", 99.88); AccountNode n3 = new AccountNode(3003, "John Rosa", 5.55); instac.push(n1); instac.push(n2); instac.push(n3); System.out.println(instac.pop().name); System.out.println(instac.pop().name); System.out.println(instac.pop().name); } } /* if your classes are correctly implemented, it will display:

John Rosa Alex Bush Janet Smith

*/

public class AccountNode { public int account_number; public String name; public double balance; public AccountNode(int v, String n, double b) { this.account_number = v; this.name = n; this.balance = b; } }

In this assignment, you are going to work on a data structure AccountStack to store data objects called AccountNode. AccountNode is a data structure used to store account information and has three fields: account_number (int), name (String), and balance (double). account_number name balance I have created the skeleton of both an array implementation and a linkedlist implementation of class AccountStack

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!