Please help me... i need some code

Hi, i am new to Java programming, but i have a dillema. I am trying to teach myself how to use Link Lists, and have been successful in the implementation, except for adding code to delete a node. If someone would please email me to help, i would really appreciate it. I will send my code i have so far, and i just need someone to write a delete method for me. Please help, i am so frustrated, i just want to see a working example. thanks. my email address is [email protected]
Thanks in advance.

Ok, good idea. I am writing a program that adds 7 CD objects to a LinkList, and then prints the list. Then it removes any two, and prints the list again. I have three classes though, so ill try to make it as readable as possible:
Here is the class which sets up the Compact disc object:
public class CompactDisc
private String title
// Sets up the new CompactDisc with its title.
public CompactDisc (String newTitle)
title = newTitle;
// Returns this CD as a string.
public String toString ()
return title;
Here is the class with the CD list:
public class CDList
private CDNode list;
// Sets up an initially empty list of cds
public CDList()
list = null;
// Creates a new CDNode object and adds it to the end of
// the linked list.
public void add (CompactDisc cd)
CDNode node = new CDNode (cd);
CDNode current;
if (list == null)
list = node;
else
current = list;
while (current.next != null)
current = current.next;
current.next = node;
public void delete(CompactDisc cd)
// HERE IS WHERE I NEED THE CODE!!!!
// Returns this list of CDs as a string.
public String toString ()
String result = "";
CDNode current = list;
while (current != null)
result += current.compactdisc + "\n";
current = current.next;
return result;
// An inner class that represents a node in the CD list.
// The public variables are accessed by the CDList class.
private class CDNode
public CompactDisc compactdisc;
public CDNode next;
// Sets up the node
public CDNode (CompactDisc CD)
compactdisc = CD;
next = null;
And here is the Driver Class:
public class CDRack
// Creates a CDList object, adds several CDs to the
// list, then prints it.
public static void main (String[] args)
CDList rack = new CDList();
rack.add (new CompactDisc("The Four Seasons")); // Vivaldi
rack.add (new CompactDisc("Caught Somewhere In Time")); // Iron Maiden
rack.add (new CompactDisc("New York City Underground Mix")); // Louie Devito
rack.add (new CompactDisc("Whoracle")); // In Flames
rack.add (new CompactDisc("Straight Outa' Compton")); // NWA
rack.add (new CompactDisc("Elegy")); // Amorphis
rack.add (new CompactDisc("Butterfly")); // Mariah Carey
System.out.println (rack); // initially print the entire list
System.out.println ("Deleting a node from the list");
// code goes here to delete a node (e.g.. rack.delete(somenode); )
System.out.println(rack); print the list with two nodes deleted
Please help me with this. I would prefer if someone could just add the method and corresponding call to make the program delete. Then i would observe the code, and hopefully learn something. thanks.

Similar Messages

  • PLEASE HELP!! Need some way to read header text in advanced datagrid using QTP

    I am writing a function to read column names in advanced data
    grid. There is no operation for that and any of the properties that
    I can use to read the column names.
    Please suggest any way that I can get the names of columns in
    the advanced data grid.
    Thanks

    I hope to hear something from adobe folks...I am providing
    more info.....
    I am using QTP 9.2 and Flex 3 add-in available from Adobe.
    My application has flex Advanced datagrid object and I am
    trying to read column names for the datagrid.
    I have contacted developers and they told me that column
    names for flex advanced datagrid are stored in "Header Text"
    I have tried reading "Header Text" using
    GetROProperty("HeaderText") but it doesn't return anything.
    I have tried the following code:
    x =
    Browser("app").FlexApplication("flexapp").FlexCanvas("Canvas").FlexAdvancedDatagrid("esti mategridid").GetROProperty("Header
    Text")
    msgbox x
    I have also tried getting value for column names using other
    available properties for webtables like outerhtml, outertext, alt
    etc. but I don't get any data.
    Part of the problem may be because none of the above
    mentioned properties are supported by Flex Advanced datagrid.
    I have also tried getting child objects but I always get the
    data in datagrid as values but not the column names.
    My primary reason for getting column names is to write a
    function to update cell in datagrid independent of application. So,
    I want to pass column name as a parameter to the function and get
    the corresponding columnIndex in the function by comparing the
    parameter value against column names.
    Thanks to all for you help...

  • Please help me transform this C++ code to java code....

    guys...please help me transform this C++ code to java code....please try to explain the code..thanks
    [program]
    #include <stdio.h>
    #define ALIVE 1
    #define DEAD 0
    #define SZ 33
    int stschk (int ,int );
    main()
    int s[SZ][SZ], i, j;
    for (i=0; i<sz; i++ ) s[0] = DEAD;
    for (j=0; j<sz; j++ ) s[0][j] = DEAD;
    s[0][1] = ALIVE;
    for (i=0; i<sz-1; i++) {
    for ( j=1;j<sz;j++ ) {
    s[i][j] = stschk(s[i][j-1],s[i+1][j];
    if(s[i][j-1]==ALIVE) printf("*");
    else printf(" ");
    printf("\n");
    int stschk(int s1,int s2)
    if(((s1==DEAD)&&(s2==ALIVE))||
    ((s1==ALIVE)&&(s2==DEAD))) return ALIVE;
    else return DEAD;

    Being picky, that's not C++, that's C. Standard headers in C++ dont' have .h after them, loop variables are scoped with the for, you use constants rather than #defines, etc..
    C and C++ both don't initialise arrays by default; you'd have to write an initialiser to get it to zero out the array:
        int s[sz][sz] = {};gcc will insert a call to memset to zero the array.
    If the author was assuming that the array was zeroed out, there would be no point zeroing the first row and column.
    The code reads values which haven't been initialised. If you mark such values explicitly undefined, and change the program to report an error when undefined, then you get several cases where the program makes such report.
    So either it' s a primitive random number generator (some random number generators use uninitialised memory as a source of randomness), or it's buggy, or it's processing undefined data and throwing away the result. Either way, it cannot be directly be ported to Java if the undefined values (which are limited to a small area of the ouput) are significant.

  • I forgot restrictions cod in ipad air1 and don't off it , please help me for recovery this cod

    i forgot restrictions cod in ipad air1 and don't off it , please help me for recovery this cod...

    Locked Out, Forgot Lock or Restrictions Passcode, or Need to Restore Your Device: Several Alternative Solutions
    A
    1. iOS- Forgotten passcode or device disabled after entering wrong passcode
    2. iPhone, iPad, iPod touch: Wrong passcode results in red disabled screen
    3. Restoring iPod touch after forgotten passcode
    4. What to Do If You've Forgotten Your iPhone's Passcode
    5. iOS- Understanding passcodes
    6. iTunes 10 for Mac- Update and restore software on iPod, iPhone, or iPad
    7. iOS - Unable to update or restore
    Forgotten Restrictions Passcode Help
                iPad,iPod,iPod Touch Recovery Mode
    You will need to restore your device as New to remove a Restrictions passcode. Go through the normal process to restore your device, but when you see the options to restore as New or from a backup, be sure to choose New.
    You can restore from a backup if you have one from BEFORE you set the restrictions passcode.
    Also, see iTunes- Restoring iOS software.
    And also see How to Recover Forgotten iPhone, iPad Restrictions Passcode.

  • Please help me to complete this code

    import java.security.MessageDigest;
    import java.util.Map;
    import java.util.Scanner;
    public class PasswordService
       //The hash is to be formed using the SHA algorithm
       //to create a MessageDigest
       private final String algorithmName = "SHA";
       //Use a message digest to create hashed passwords
       private MessageDigest md = null;
       //We simulate a database of users using who have a login and password
       //as a key and value pair in a Map
       private Map<String, byte[]> userData;
       //complete the constructor
       public PasswordService()
         //TODO - intialize the class instance data
          //some dummy data - do not alter these lines
          addUser("daddy", "cool");
          addUser("nightflight", "topChat");
          addUser("boney", "2E5sxuSRg6A");
       public void showProvider()
          //TODO
       //Get the hash value for the provided string password.
         public byte[] getHash(String password)
          //TODO
          return null;
       public void addUser(String login, String password)
          //TODO
       public byte[] getPassword(String login)
          //TODO
          return null;
       public boolean checkLogin(String login, String password)
         // TODO
          return false;
       //This method is provided to perform a login from the command line
       public boolean doLogin()
          Scanner sc = new Scanner(System.in);
          System.out.println("Enter login please");
          String login = sc.next();
          System.out.println("Your password please");
          String password = sc.next();
          return checkLogin(login, password);
       public static void main(String[] args)
          int attempts = 0;
          showProvider();
          while(attempts < 4)
             boolean match = doLogin(); //request login and password
             System.out.println("match? " + match);
             attempts++;
    }

    please help me to complete this code
    void completeCode(Code code,Properties options) throws CodeCompletingException
    CodeCompleterFactory cf = CodeCompleterFactory.newInstance();
    CodeCompleter cc = cf.newCodeCompleter();
    cc.complete(code,options);
    }

  • Can somebody please tell me how to fix this. when i try to install appleworks this pops up  so please help me i need to get this on my mac

    can somebody please tell me how to fix this. when i try to install appleworks this pops up
    so please help me i need to get this on my mac

    AppleWorks is a very old application and requires Rosetta to run under recent systems.
    Lion does not include Rosetta.
    If you browse this forum you will find many posts on this issue.

  • HT4199 I just got a new iPod touch 4th generation and I'm trying to connect to my router and my iPod says, 'Cannont find network.' I don't know what to do! No other networks come up on the list so I can't 'tag' along with thier wifi. Please help. I need a

    I just got a new iPod touch 4th generation and I'm trying to connect to my router and my iPod says, 'Cannont find network.' I don't know what to do! No other networks come up on the list so I can't 'tag' along with thier wifi. Please help. I need advice.

    What type network is yu router set up for? The 4G iPod can only connect and see 2.4 GHZ networl like B, G and the 2,4 GHz N. There is also a 5 GHz N but the iPod will not even seethat network.
    See:
    iOS: Troubleshooting Wi-Fi networks and connections
    iOS: Recommended settings for Wi-Fi routers and access points

  • My itunes will not! is giving me error7(windows error 126) and is stilling me MSVCR80.dll is missing and i tried downloading itunes like 6 times and is saying the same thing. Please help! i need to sync my kids ipads and ipods thank you!

    my itunes will not open! is giving me error7(windows error 126) and is stilling me MSVCR80.dll is missing and i tried downloading itunes like 6 times and is saying the same thing. Please help! i need to sync my kids ipads and ipods
    thank you!

    Follow the instructions of tt2 given in https://discussions.apple.com/thread/5822086

  • HT201269 I forgot my password for Encrypt my Backup how can I reset that please help I really need it Urgently???

    I forgot my password for Encrypt my Backup how can I reset that please help I really need it Urgently?

    If you do not know the passcode then you cannot use the backup
    Sorry

  • Please Help! I need to delet "Fellow member" on Sk...

    Please Help!
    I need to delete a "Fellow member" on the Skype manager. I don't know what is "Skype manager" and why the user Greiman Gomez Garcia (scanman113)  is registered there, I DON'T KNOW HIM.
    I already have seen the screens on the FQA, but I never can get to those.
    I'm logging on web.
    Thank you very much for your answer.

    Hi, moremay, and welcome to the Community,
    Your report reads as if your account may have been compromised.  Can you still sign in to your account dashboard?  If yes, check that the account's registered e-mail address is accurate and valid.  Then, change your account's password - I prefer to do this from within the Skype software itself.  After this, you can contact Skype Customer Service to close the "Skype Manager" set-up.
    If you can not access your account, create a new account to use in order to contact Skype Customer Service and to recover your first account, as well as to disengage the "Skype Manager" which account hackers tend to use when they hack accounts.
    Here is a link to the instruction on how to contact Skype Customer Service via their secure portal: Contact Customer Service
    Skype is aware of lingering problems with the website when contacting their customer service agents. If you experience difficulty reaching Skype Customer Service or find yourself redirected back to the Community, please try again using a different web browser and choosing a different path through the various drop-down menu options presented. Also, look to approve a pop-up dialogue box which would connect you to start an instant message chat with a customer service agent. If you have pop-ups blocked in your browser settings, this will also block reaching an agent.
    Regards,
    Elaine
    Was your question answered? Please click on the Accept as a Solution link so everyone can quickly find what works! Like a post or want to say, "Thank You" - ?? Click on the Kudos button!
    Trustworthy information: Brian Krebs: 3 Basic Rules for Online Safety and Consumer Reports: Guide to Internet Security Online Safety Tip: Change your passwords often!

  • Please help me, i need all driver HP ENVY m6-010dx support win 7 64 bit

    please help me, i need all driver HP ENVY m6-010dx support win 7 64 bit. 

    Double post
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • PLEASE HELP ME, I NEED ALL DRIVER HP ENVY M6-K010DX SUPPORT WIN 7 64 BIT

    please help me, i need  all driver HP ENVY m6-k010dx support win 7 64 bit

    Hi:
    Try the W7 x64 drivers and software from this model which has the same processor.
    http://h10025.www1.hp.com/ewfrf/wc/softwareCategory?os=4063&lc=en&cc=us&dlc=en&sw_lang=&product=6545...

  • Please help me to have some knowledge on this

    Can any one give me 'a model of blue print along with some examples of gaps and it's solution in the project'? Please help me to have some knowledge on this.

    /* Formatted on 8/27/2012 9:54:40 AM (QP5 v5.185.11230.41888) */
    WITH t AS (SELECT 'a-->b-->c-->d' tree FROM DUAL),
         t1
         AS (    SELECT REGEXP_SUBSTR (tree,
                                       '[^-->]+',
                                       1,
                                       LEVEL)
                           parent,
                        REGEXP_SUBSTR (tree,
                                       '[^-->]+',
                                       1,
                                       LEVEL + 1)
                           child,
                        LEVEL lvl
                   FROM t
             CONNECT BY LEVEL <= REGEXP_COUNT (tree, '-->') + 1)
        SELECT DISTINCT PRIOR parent || '-->' || parent PATH
          FROM t1
         WHERE PRIOR parent IS NOT NULL
    CONNECT BY PRIOR lvl < lvl
    c-->d
    a-->d
    a-->b
    b-->d
    b-->c
    a-->c

  • I just exchanged a faulty iPhone 4 for a new one, when I got home to restore it, iCloud says "cannot restore backup". Can somebody please help provide much needed advice? Thanks in advance!

    I just exchanged a faulty iPhone 4 for a new one, when I got home to restore it, iCloud says "cannot restore backup". Can somebody please help provide much needed advice? Thanks in advance!

    Yep, that's the only message that popped out. Nothing else. Yes, it's running on the latest ios and I still can't restore it. I called apple and they told me it's probably something wrong with their servers. Anyway thanks for the advice.

  • I ordered mac OS and I got the email for License and I didnt get the attachement for content code. Please help me getting the content code.

    I ordered mac OS and I got the email for License and I didnt get the attachement for content code. Please help me getting the content code.

    It's a two email process, one email has a locked pdf with the redemption code. The second email has the password to unlock the pdf. They come separetly, so you may have to wait for the 2nd to arrive.

  • My battery on my iphone theree is growning and it turns off around 80% then in order for it to turn back on i need to put it on the charger , somebody please help me i need to fix this is there anyway  ican??

    my battery on my iphone three is growning and it turns off around 80% then in order for it to turn back on i need to put it on the charger , somebody please help me i need to fix this is there anyway  ican?

    Basic troubleshooting from the User's Guide is reset, restart, restore (first from backup then as new).  Try each of these in order until the issue is resolved.
    If the issue persists, then take the device to Apple for evaluation.
    FYI, Apple will not replace the battery without first doing basic troubleshooting or testing the battery.

Maybe you are looking for

  • Error : Reading from Aggregation Level not permitted

    Hello Gurus,       Could somebody please give some help or advice regarding this? I have a multiprovider on a regular cube and an aggregation level, for some reason the multicube gives me the following error message when I try to display data using l

  • JD12 JSF designer does not redraw

    I am having many issues in JD12 JSF designer. One is that when I for example select a navigation button's spacer and change it's Width property, the space between buttons does not change until file is closed and re-opened. Is that expected behaviour?

  • SAPGUI + MAC

    Hi all, I cannot connect because I heve the error below: Error: partner '85.36.223.36:3209' not reached Thu Feb 10 12:15:26 2011 Release 710 Component NI (network interface), version 39 rc = -10, module nibuf.cpp, line 4634 Detail NiBufIConnect: conn

  • Maximum Digits for Extension in Callmanager 4.X

    What's the official maximum number of digits for extensions in CM 4.x? The error message says it's 24 and I got this information that it is supposed to support 32.

  • How can an artist show as a search result yet not exist in the artist list?

    I'm trying to import music from the My Music folder on my computer. I followed the steps outlined in the iTunes tutorial. When I search for the song, the artist and album show as search results, but the song does not. When I follow the link from the