Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-24-2007, 08:09 PM
Member
 
Join Date: Dec 2007
Posts: 1
ephem is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-24-2007, 10:53 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
I copied the methods from the Stack class spi.
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) { } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Executing a program within a program gibsonrocker800 New To Java 5 05-12-2008 10:24 AM
How to execute an External Program through Java program Java Tip java.io 0 04-04-2008 04:40 PM
a few questions on structuring my program... sdkevinb New To Java 0 02-06-2008 08:48 AM
How to execute an External Program through Java program JavaBean Java Tips 0 10-04-2007 11:33 PM
I need help with this program Daniel Advanced Java 2 07-04-2007 07:14 AM


All times are GMT +3. The time now is 02:24 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org