Friday, February 28, 2014

Need help with a UML diagram involving stacks








I am very new to Java. I've taken the beginner's course at my local community college and am now in the second part, so my understanding is very rudimentary and I ask your patience.








Anyway, we are working with stacks which so far are completely blowing my poor little brain away. We were given a UML diagram to work on for homework. I've got the basic skeleton of the class written, but not sure how to write the methods. My professor and our book is no help, so I'm turning to you for assistance. I'm not asking you to write my program for me, just give me a few pointers on where I should go from here. I'll attach a picture of the UML diagram and the code I already have written.








FYI: He messed up what he wanted the names in the private class Node to be, I wrote in the corrections. And the little scribble to the side was just me being indecisive about where I was going to write the correction and scratching it out








Need help with a UML diagram involving stacks-uml.jpg












Java Code:











import java.util.*;

public class Stack
{
private class Node
{
private Node link;
private int info;
}

private Node first, newNode, current;
private int size;

public void push(int i)
{
}
public int peek()
{
}
public int pop()
{
}
public boolean isEmpty()
{
}
public int getSize()
{
}
public void printStack()
{
}
}









I'm not too worried about the exception handling or the "empty stack" portions, I can't imagine having any trouble with that. Writing the application program shouldn't be a problem either. Again, I'm not looking to have my program written for me, I'm just at a bit of a loss as to where to start. I grasp the basic concepts of stacks, I'm just struggling to write one the way he wants it. Please let me know if I should provide more information, I'll do my best.










No comments:

Post a Comment