java programming help

Discussion in 'OT Technology' started by djnick, Feb 27, 2006.

  1. djnick

    djnick wannabe dj OT Supporter

    Joined:
    Aug 17, 2004
    Messages:
    10,062
    Likes Received:
    1
    Location:
    fresh coast.
    dfser5abw4azwv
     
    Last edited: Mar 12, 2006
  2. Aimless

    Aimless Resident drunkey

    Joined:
    Nov 5, 2001
    Messages:
    2,534
    Likes Received:
    0
    Location:
    Wisconsin
    There's no way anyone's going to read that.
     
  3. djnick

    djnick wannabe dj OT Supporter

    Joined:
    Aug 17, 2004
    Messages:
    10,062
    Likes Received:
    1
    Location:
    fresh coast.
    u dont have to read all of it, first paragraph basically summarizes it
     
  4. wparsons

    wparsons New Member

    Joined:
    Feb 21, 2006
    Messages:
    62
    Likes Received:
    0
    I read the whole thing.. What exactly are you stuck on?? My suggestion would be to start where the prof suggested, by getting the skip-list working correctly. Once you have that, then its just a matter of adding some methods, and conditional statements to handle(and do something with) input.
     
  5. djnick

    djnick wannabe dj OT Supporter

    Joined:
    Aug 17, 2004
    Messages:
    10,062
    Likes Received:
    1
    Location:
    fresh coast.
    any code examples on how to impelement skip lists, we just learned the theory behind it but not how to code it in java
     
  6. wparsons

    wparsons New Member

    Joined:
    Feb 21, 2006
    Messages:
    62
    Likes Received:
    0
    I've never had to code a skip list, and to be honest I don't really remeber the theory behind them either.

    I'd suggest writing out the steps for making/using a skip list in plain english, then converting that to java.
     
  7. Yep

    Yep Knick knack paddy whack, give the old dog a bone

    Joined:
    Jan 22, 2001
    Messages:
    4,603
    Likes Received:
    0
    Location:
    South Jersey
    You're instructor definately believes in hands on eh? Usually, they'll throw some code examples at you and let you reference or combine them in to something useful.
     
  8. antiyou

    antiyou OT Supporter

    Joined:
    Jul 13, 2005
    Messages:
    25,295
    Likes Received:
    0
    Location:
    in ur base
    well start with a skiplist class with a nested skipnode class
    the node will contain the data, a set of forward references, and a size(number of levels)

    you will need methods to get and set the data as well as the references

    in your skiplist you will need insert delete and find methods. some of which may require "helper methods"
     
  9. djnick

    djnick wannabe dj OT Supporter

    Joined:
    Aug 17, 2004
    Messages:
    10,062
    Likes Received:
    1
    Location:
    fresh coast.
    antiyou you got pm.

    here is my skiplist what should i do after. if you can download it and add some stuff would be great

     
    Last edited: Mar 3, 2006
  10. antiyou

    antiyou OT Supporter

    Joined:
    Jul 13, 2005
    Messages:
    25,295
    Likes Received:
    0
    Location:
    in ur base
    Once you verify your skiplist is working properly. You can begin writing your main function now. Your main object should contain a skiplist object. You know that you will be inserting book objects into your skiplist so you will need to create a class book object containing
    ISBNKey
    author
    title
    publisher
    year
    all represented as strings

    Now you should read commands and process them accordingly. Use a string command with a set of if elses.
    //read command
    while(command != Exit)
    {
    if(command == "Insert")
    //read the isbn key
    //look for it in the skip list
    //if no book is found with that isbn
    //create a new book object with the values in the input file
    //Insert that book into the skiplist
    else if (command == LookUp)

    else if (command == Delete)

    else
    //invalid command output error

    //read next command
    }

    return 0;

    You know that you continue to process commands until the use enters exit. You also know that you are not to prompt the user for commands.
     
  11. djnick

    djnick wannabe dj OT Supporter

    Joined:
    Aug 17, 2004
    Messages:
    10,062
    Likes Received:
    1
    Location:
    fresh coast.
    looks good in psuedocode, but im having problems implementing it. how does it look in java?
     
  12. antiyou

    antiyou OT Supporter

    Joined:
    Jul 13, 2005
    Messages:
    25,295
    Likes Received:
    0
    Location:
    in ur base
    Code:
    public class book{
    
    string ISBNKey,
             author,
             title,
             publisher,
             year;
    
              // add set member functions
              // add constructor and default constructor
    
              //add accessor function for ISBNkey
              //add print fuction that will output the value for each variable
    
    }
    class SkipListApp{
    
        public static void main (String args[])
        {
            SkipList dataBase;
            InputStreamReader inputStream =  new InputStreamReader(system.in);
            BufferedReader bufferStream = new BufferReader(inputStream);
            string line = bufferStream.readline(), command;
             while(line != null)
            {
                 StringTokenizer st = new StringTokenizer(line);
                 while (st.hasMoreTokens())
                 {
                     command = st.nextToken();
                     if(command == "INSERT")
                     {
                         //get the next token ISBNkey;
                           if(dataBase.find(key))
                               system.out.println("This Book is Already in the Database");
                           else
                           { 
                               //read rest of tokens into string
                               //create new book object passing in the values from lines into the 
                               // constructors parameters
                               Book newBook(...);//the parameters are book values
                               dataBase.Insert(newBook);
                            }
                           
                     }
                     else if(command == "LOOKUP")
                     {
                         ;
                     }
                     else if(command == "DELETE")
                     {
                         ;
                     }
                     else if(command == "EXIT")
                     {
                        ;
                     }
                     else 
                         system.out.println("error");
                }
    
                line = bufferStream.readline();
            }
    
         }
    }
    
    
     
    Last edited: Mar 3, 2006
  13. djnick

    djnick wannabe dj OT Supporter

    Joined:
    Aug 17, 2004
    Messages:
    10,062
    Likes Received:
    1
    Location:
    fresh coast.
    thanks man appreciate it i will post back when i get it all put together
     
  14. bradpitt

    bradpitt New Member

    Joined:
    Feb 22, 2005
    Messages:
    982
    Likes Received:
    0
    Location:
    █ i'm #1, hollywood █
    whats the point of writing the code for him? now hes not gonna learn shit
     
  15. Aimless

    Aimless Resident drunkey

    Joined:
    Nov 5, 2001
    Messages:
    2,534
    Likes Received:
    0
    Location:
    Wisconsin
    It'll catch up to him in the end.
     
  16. djnick

    djnick wannabe dj OT Supporter

    Joined:
    Aug 17, 2004
    Messages:
    10,062
    Likes Received:
    1
    Location:
    fresh coast.
    the guy wrote like half a class for me. i pretty much did everything else wtf u talking about
     
  17. antiyou

    antiyou OT Supporter

    Joined:
    Jul 13, 2005
    Messages:
    25,295
    Likes Received:
    0
    Location:
    in ur base
    I didn't even write a whole function...he can figure it out from there...


    if you notice the main code he needs to write is comented
     

Share This Page