Results 1 to 2 of 2
Thread: structuring the program
- 12-24-2007, 06:09 PM #1
Member
- Join Date
- Dec 2007
- Posts
- 1
- Rep Power
- 0
structuring the program
Hi im new to java and trying to write my first program (using stacks).
Im somewhat confused about how to structure the program. Im use to using a modular language similar to pascal.
So im trying to implent a stack and operations associated (constructors, observers, modifiers).
Pop, Push Isempty etc...
Firstly i need to create a new stack. Will this be my Class?
The operations associated need to be there too (im use to writing procedures for each operation, within one module). Im unsure about how to pass numbers or objects to be inserted into the empty stack - how to initialise it and where.
Could somewhat just outline the structure they would expect to use (not so much code but layout).
thanks
- 12-24-2007, 08:53 PM #2
I copied the methods from the Stack class spi.
Java Code:public class TestMyStack { public static void main(String[] args) { MyStack stack = new MyStack(); stack.push(new E()); } } class MyStack { public MyStack() { } // Tests if this stack is empty. public boolean empty() { } // Looks at the object at the top of this // stack without removing it from the stack. public E peek() { } // Removes the object at the top of this // stack and returns that object as the // value of this function. public E pop() { } // Pushes an item onto the top of this stack. public E push(E item) { } // Returns the 1-based position where an // object is on this stack. public int search(Object o) { } }
Similar Threads
-
Executing a program within a program
By gibsonrocker800 in forum New To JavaReplies: 5Last Post: 05-12-2008, 08:24 AM -
How to execute an External Program through Java program
By Java Tip in forum java.ioReplies: 0Last Post: 04-04-2008, 02:40 PM -
a few questions on structuring my program...
By sdkevinb in forum New To JavaReplies: 0Last Post: 02-06-2008, 06:48 AM -
How to execute an External Program through Java program
By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 09:33 PM -
I need help with this program
By Daniel in forum Advanced JavaReplies: 2Last Post: 07-04-2007, 05:14 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks