Help with linked lists and searching

Hi guys I'm very new to java. I'm having a problem with linked lists. the program's driver needs to create game objects, store them, be able to search the linked list etc. etc. I've read the API but I am really having trouble understanding it.
First problem is that when I make a new game object through the menu when running the program, and then print the entire schedule all the objects print out the same as the latest game object created
Second problem is searching it. I just really have no idea.
Here is the driver:
import java.util.*;
public class teamSchedule
     public static void main (String[]args)
          //variables
          boolean start;
          game game1;
          int selector;
          Scanner scanner1;
          String date = new String();
          String venue = new String();
          String time = new String();
          String dateSearch = new String();
          double price;
          String opponent = new String();
          int addindex;
          List teamSchedLL = new LinkedList();
          String dateIndex = new String();
          String removeYN = new String();
          String venueIndex = new String();
          String opponentIndex = new String();
          start = true; //start makes the menu run in a while loop.
          while (start == true)
               System.out.println("Welcome to the Team Scheduling Program.");
               System.out.println("To add a game to the schedule enter 1");
               System.out.println("To search for a game by date enter 2");
               System.out.println("To search for a game by venue enter 3");
               System.out.println("To search for a game by opponent enter 4");
               System.out.println("To display all tour information enter 5");
               System.out.println("");
               System.out.println("To remove a game from the schedule enter search for the game, then"
                                        + " remove it.");
               System.out.println("");
               System.out.println("Enter choice now:");
               scanner1 = new Scanner (System.in);
               selector = scanner1.nextInt();
               System.out.println("");
               if (selector == 1)
                    //add a game
                    scanner1.nextLine();
                    System.out.println("Adding a game...");
                    System.out.println("Enter game date:");
                    date = scanner1.nextLine();
                    System.out.println("Enter game venue:");
                    venue = scanner1.nextLine();
                    System.out.println("Enter game time:");
                    time = scanner1.nextLine();
                    System.out.println("Enter ticket price:");
                    price = scanner1.nextDouble();
                    scanner1.nextLine();
                    System.out.println("Enter opponent:");
                    opponent = scanner1.nextLine();
                    game1 = new game(date, venue, time, price, opponent);
                    teamSchedLL.add(game1);
                    System.out.println(teamSchedLL);
                    System.out.println("Game created, returning to main menu. \n");
                    start = true;
               else if (selector == 2)
                    //search using date
                    scanner1.nextLine();
                    System.out.println("Enter the date to search for in the format that it was entered:");
                    dateIndex = scanner1.nextLine();
                    if (teamSchedLL.indexOf(dateIndex) == -1)
                         System.out.println("No matching date found.  Returning to main menu.");
                         start = true;
                    else
                         //give user option to remove game if they wish.
                         System.out.println(teamSchedLL.get(teamSchedLL.indexOf(dateIndex)));
                         System.out.println("Would you like to remove this game? Y/N");
                         removeYN = scanner1.nextLine();
                         if (removeYN == "Y" || removeYN == "y")
                              teamSchedLL.remove(teamSchedLL.indexOf(dateIndex));
                              System.out.println("Scheduled game removed.");
                    System.out.println("\n Returning to main menu. \n");
                    start = true;
               else if (selector == 3)
                    //search using venue name
                    scanner1.nextLine();
                    System.out.println("Enter the venue to search for in the format that it was entered:");
                    venueIndex = scanner1.nextLine();
                    if (teamSchedLL.indexOf(venueIndex) == -1)
                         System.out.println("No matching venue found.  Returning to main menu.");
                         start = true;
                    else
                         //give user option to remove game
                         System.out.println(teamSchedLL.get(teamSchedLL.indexOf(venueIndex)));
                         System.out.println("Would you like to remove this game? Y/N");
                         removeYN = scanner1.nextLine();
                         if (removeYN == "Y" || removeYN == "y")
                              teamSchedLL.remove(teamSchedLL.indexOf(venueIndex));
                              System.out.println("Scheduled game removed.");
                    System.out.println("\n Returning to main menu. \n");
                    start = true;
               else if (selector == 4)
                    //search using opponent name
                    scanner1.nextLine();
                    System.out.println("Enter the opponent to search for in the format that it was entered:");
                    opponentIndex = scanner1.nextLine();
                    if (teamSchedLL.indexOf(opponentIndex) == -1)
                         System.out.println("No matching opponent found.  Returning to main menu.");
                         start = true;
                    else
                         //give user option to remove game
                         System.out.println(teamSchedLL.get(teamSchedLL.indexOf(opponentIndex)));
                         System.out.println("Would you like to remove this game? Y/N");
                         removeYN = scanner1.nextLine();
                         if (removeYN == "Y" || removeYN == "y")
                              teamSchedLL.remove(teamSchedLL.indexOf(opponentIndex));
                              System.out.println("Scheduled game removed.");
                    System.out.println("\n Returning to main menu. \n");
                    start = true;
               else if (selector == 5)
                    //display tour info
                    System.out.println("Tour Schedule:");
                    System.out.println(teamSchedLL + "\n");
               else
                    System.out.println("Incorrect choice entered. Returning to menu");
                    System.out.println("");
                    System.out.println("");
                    System.out.println("");
and here is the game class:
public class game
     private static String gameDate;
     private static String gameVenue;
     private static String gameTime;
     private static double gamePrice;
     private static String gameOpponent;
     public static String gameString;
     //set local variables equal to parameters
     public game(String date, String venue, String time, double price, String opponent)
          gameDate = date;
          gameVenue = venue;
          gameTime = time;
          gamePrice = price;
          gameOpponent = opponent;
     //prints out info about the particular game
     public String toString()
          gameString = "\n --------------------------------------------------------";
          gameString += "\n Date: " + gameDate + " | ";
          gameString += "Venue: " + gameVenue + " | ";
          gameString += "Time: " + gameTime + " | ";
          gameString += "Price: " + gamePrice + " | ";
          gameString += "Opponent: " + gameOpponent + "\n";
          gameString += " --------------------------------------------------------";
          return gameString;
}I'm sure the formatting/style and stuff is horrible but if I could just get it to work that would be amazing. Thanks in advance.
Message was edited by:
wdewind

I don't understand your first problem.
Your second problem:
for (Iterator it=teamSchedLL.iterator(); it.hasNext(); ) {
game game = (game)it.next();
// do the comparation here, if this is the game want to be searched, then break;
}

Similar Messages

  • Help with linked list code.

    Here's a basic linked list code that I need help on.
    What I need assistance with:
    1. How would I rewrite and delete words/phrases in the file IO section of my code?
    2. How would I make the code recognize all the words on each line of the linked list? Only the words on the first line of the file go into the linked list.
    import java.util.LinkedList;
    import java.io.*;
    import javax.swing.JOptionPane;
    public class LinkedLists {
        public static void delete (LinkedList test)
            int a = Integer.parseInt(JOptionPane.showInputDialog(null,
            "Enter a position to delete"));
            test.remove(a - 1);
            System.out.print(test);
        public static void add (LinkedList test)
            String user = JOptionPane.showInputDialog(null, "What to input?");
            int b = Integer.parseInt(JOptionPane.showInputDialog(null,
                    "What position to enter it in?"));
            test.add(b - 1, user);
            System.out.print(test);
        public static void fileRead(LinkedList test) throws IOException
            BufferedReader fileIn;
            String text;
            fileIn = new BufferedReader(new FileReader("z:/data.txt"));
            text = fileIn.readLine();
            fileIn.close();
            int b = Integer.parseInt(JOptionPane.showInputDialog(null,
                    "What position to enter it in?"));
            test.add(b - 1, text);
            System.out.print(test);
        public static void fileWrite(LinkedList test) throws IOException
            PrintWriter fileOut;
            fileOut = new PrintWriter(new FileWriter("z:/data.txt",true));
            String user = JOptionPane.showInputDialog(null, "What to input?");
            fileOut.println(user);
            fileOut.close();
            fileRead(test);
        public static void main(String[] args)  {
            LinkedList test = new LinkedList();
            test.addLast("Fly");
            test.addLast("money");
            test.addLast("awesome");
            test.addLast("woot");
            test.addLast("yay");
            System.out.print(test);
            System.out.println();
            int x = Integer.parseInt(JOptionPane.showInputDialog(null,
                    "Enter \n1 to Delete \n2 to Add \n3 to read data from file \n4 to write into the file and add to list"));
            if (x == 1) {
                delete(test);
            if (x == 2) {
                add(test);
            if (x == 3) {
                try {
                    fileRead(test);
                } catch (IOException e) {
                    e.printStackTrace();
            if(x==4)
                try {
                    fileWrite(test);
                } catch (IOException e) {
                    e.printStackTrace();
    }Edited by: Johnston on Sep 16, 2007 1:13 AM

    Hi,
    Johnston wrote:
    1. How would I rewrite and delete words/phrases in the file IO section of my code?You want to replace or remove in/from the file?
    First you have to define a file format. This is not a Java technical term, but a thing what you have to keep in mind. Simplest format is:
    - each ListItem is one line in the file closed with newline.
    Now you can read the file line by line and store the lines in a memory structure (LinkedList for ex ;-)). Then replace or remove the designated elements an write the file new by iterate over the list and write each item as line in the file.
    Johnston wrote:
    2. How would I make the code recognize all the words on each line of the linked list? Only the words on the first line of the file go into the linked list.You have to read the file line by line and then add each line as item of the list.
    Examples for reading/writing textfiles:
    http://www.exampledepot.com/egs/java.io/pkg.html#Reading%20and%20Writing
    Btw: Deal with Generics (see http://java.sun.com/docs/books/tutorial/extra/generics/index.html) an use this knowledge to declate your List better.
    greetings
    Axel

  • Need help with linked lists.

    I have a school assignment to make a linked list with a linked list.
    The first basic is to make a list of people, and link them together in a linked list. So far, so good.
    The problem comes when I'm going to make linked lists in each of these objects that include the relationships between the people in it.
    So If I have 10 peolpe in a list, person 1 might know person 3, 4 and 8. They will all know person 1 back of course. My problem is that it isn't just one group of friends, person 3 might not know person 4 and 8, but maybe he knows person 10. So all need "their own" list.
    Therefor I can't see how I'm supposed to use linked lists for them, as I can't just link them togeter with e.g. "Person nextFriend;" The text says specifically to use linked lists. Well, I'm stuck.
    Edited by: Skruf on Jan 27, 2009 3:22 PM

    Skruf wrote:
    I know it doesn't matter what the objects represent, I just needed a way to explain.
    But a linked list is basically just a redirect to the next in the list, right?No, a linked list is a particular implementation of a list.
    Then I can't see how it's possible to make individual friend lists.No clue what problem you're having.
    People with links
    null - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - nullThat means nothing.
    I can't see how that can be used to make independent links. Do they mean that I'm support to stort it in arrays or something then?
    The person list, is (as you can see in my "illustration") only a "next" and "previous" person, so I can't use that way to link the friends together. nextFriend and lastFriend obviously doesn't work.
    That's my problemLike I said: A Person object contains a linked list. In that linked list you put references to that Person's friends.

  • Help with LINK WARNINGS and ROLLOVERS in GoLive CS3

    Hello,
    After I publish my site, I am unable to get the rollovers to work. Could this because I am getting Link Warning messages on all of the pages? I have been troubleshooting for a few hours and can not seem to find the problem. I could use a fresh set of eyes if anyone has the time to look at the code. When I view the site in my browser before I publish it, the rollovers work fine. I am just looking to get the rollovers to work. Any help is appreciated!!
    Best,
    Craig

    I forgot to list the site: www.elysiumfilm.com

  • Getting null returned when working with Linked Lists

    Ok, i'm having the same problem with a couple of methods that deal with linked lists, and i was hoping someone could lend me a hand. First off, the specifications for one of the methods:
    An iterative procedure smallElements
    PARAMETERS: a ListItem reference, ls
    an integer n
    RETURN VALUE: a new list identical to the given list, except
    that it contains no occurrences of numbers greater than n.
    for example, given input list ( 3 2 6 3 4 ) and 3,
    the return value would be the list ( 3 2 3 )
    And here is my code:
    ListItem smallElements(ListItem ls, int n){
    ListItem small = null;
    ListItem result = small;
    if(ls == null)
    return null;
    else{
    while(ls!=null){
         if(ls.number <=n){
         result = new ListItem(ls.number, null );
         result = result.next;
         ls = ls.next;
    return small;
    Like the topic says, i keep getting null returned as a value. I have tried setting small= new ListItem(ls.number, null), and that actually returns the correct list, except that the first number is repeated twice. I would greatly appreciate any assistance.

    I am not sure I understand your code. What exactly are those ListItems? It seems to me that you are dealing with single List elements, while the specification says that you are supposed to return a List.
    But the main error is that you have two ListItem objects there, which seems to fill the same purpose - only that you use one, and return the other. 'small', which is the one you return, never get set to anything else than null.
    I think you should do something like this: make a new, empty list to return
    for element in parameterlist
        if number is smaller than n
            add this element to returnlist
    return returnlist

  • Anyone help with linking a bank account to your apple id. The form wants a phone number I only have a UK mobile number and it doesnt sem to want to accept it keeps l;ooping me back to entering a phone number.

    Anyone help with linking a bank account to your apple id. The form wants a phone number I only have a UK mobile number and it doesnt sem to want to accept it keeps l;ooping me back to entering a phone number.

    If you are trying to setup a charge card number on the Apple Store - make sure you are in the Correct country site - icon bottom right last time I saw it - where you can change country.  

  • How  to Implement a Chained Hash Table with Linked Lists

    I'm making a migration from C/C++ to Java, and my task is to implement a Chained Hash Table with a Linked List. My problem is to put the strings(in this case names) hashed by the table using de Division Metod (H(k)= k mod N) in to a Linked list that is handling the colisions. My table has an interface implemented(public boolean insert(), public boolean findItem(), public void remove()). Any Help is needed. Thanks for everyone in advance.

    OK. you have your hash table. What you want it to do is keep key/value pairs in linked lists, so that when there is a collision, you add the key/value pair to the linked list rather than searching for free space on the table.
    This means that whenever you add an item, you hash it out, check to see if there is already a linked list and if not, create one and put it in that slot. Then in either case you add the key/value pair to the linked list if the key is not already on the linked list. If it is there you have to decide whether your requirements are to give an error or allow duplicate keys or just keep or modify one or the other (old/new).
    When you are searching for a key, you hash it out once again and check to see if there is a linked list at that slot. If there is one, look for the key and if it's there, return it and if not, or if there was no linked list at that slot, return an error.
    You aren't clear on whether you can simply use the provided linked-list implementations in the Java Collections or whether you have to cobble the linked list yourself. In any case, it's up to you.
    Is this what you're asking?
    Doug

  • Help on Linked List

    Hey people, i need a small help on my linked list.
    Ok, what i'm trying to do is have a search function with a linked list using strings. First i will have a string, i will then compute the ASCII value for that and take MOD 71 lets say. For example, a string has an ASCII value of 216, MOD 71 of this gives me 3. I will then have an array of 71, and each array will point to a linked list. There will be as many linked list as there are of arrays (71). I will then store this string at index [3] in the linked list in which the array points to.
    My problem for now is, how do i for example create 71 linked list? So far i can create only 1. To create another is easy, but if i have 71 the code will be too much. Is there an iterator i could use that easily creates 71? Sorry about this, i'm not really good with linked list with Java. Anyway, here is what i have now :).
    public class MyLinkedListElement {   
            String string;
            MyLinkedListElement next;
            public MyLinkedListElement(String s) {   
                string = s;
                next = null;   
            public MyLinkedListElement getNext() {
                return next;       
            public String getValue() {
                return string;
    public class MyLinkedList {
        public static MyLinkedListElement head;
        public MyLinkedList() {   
            head = null;
       public static void addToHead(String s) {
            MyLinkedListElement a = new MyLinkedListElement(s);
            if (head == null) {
                head = a;
            } else {
                a.next = head;
                head = a;       
        public static void main(String[] args) {
              String[] arr = {"Bubble", "Angie", "Bob", "Bubble", "Adam"};
              for (int i = 0; i < arr.length; i++) {
                          addToHead(arr);
    MyLinkedListElement current = head;
    while (current != null) {
    System.out.println(current.getValue());
    current = current.next;
    }I can have an array of strings and easily add them to a linked list.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    I am very confused now, i just need to store a string value inside an array of linked list. But i can't somehow do it. I am very close, i can store the value in a linked list but the array of linked list, this is what i have.
    public class MyLinkedListElement {   
            String string;
            MyLinkedListElement next;
            public MyLinkedListElement(String s) {   
                string = s;
                next = null;   
            public MyLinkedListElement getNext() {
                return next;       
            public String getValue() {
                return string;
    public class MyLinkedList {
        public MyLinkedListElement head;
        public MyLinkedList() {   
              head = null;
        public void addToHead(String s) {
             MyLinkedListElement  a = new MyLinkedListElement(s);
             MyLinkedList[] arrayOfLinkedLists = new MyLinkedList[71];
             for(int i = 0; i < arrayOfLinkedLists.length; i++) {
                 arrayOfLinkedLists[i] = new MyLinkedList();
             if (head == null) {    
                 head = a;
             } else {
                 a.next = head;
                 head = a;       
        public void print(MyLinkedListElement current) {
              while (current  != null) {
                    System.out.println(current.getValue());
                    current = current.next;
        public static void main(String[] args) {
              String[] arr = {"Bubble", "Angie", "Bob", "Bubble", "Adam"};
              MyLinkedList listInstance = new MyLinkedList();
              for (int i = 0; i < arr.length; i++) {
                    listInstance.addToHead(arr);
    MyLinkedListElement current = listInstance.head;
    listInstance.print(current);

  • Having trouble with Linked Lists

    I'm making a JApplet with buttons from a Linked List, and the buttons should be unique but they're all returning the same icon and string. Also my refreshImages method and deleteStudents method aren't working except for the very last button. This seems like it's just because of how Linked Lists operate, but I can't wrap my head around it.
    public class FacebookApplet extends JApplet implements ActionListener{
         private Scanner input;
         protected RefSortedList studentsList;
         protected RefUnsortedList buttonList;
         Student studentVar;
         private JButton b, refreshButton, deleteButton;
         private JPanel buttonPanel, etcPanel;
          * Calls:     readStudentNames, setUpImages
         public void init(){
              readStudentNames();
              setUpImages();
              setLayout(new BorderLayout());
              setSize(500,670);
              etcPanel = new JPanel(new BorderLayout());
              refreshButton = new JButton("Refresh");
              deleteButton = new JButton("Delete");
              buttonList.reset();
              etcPanel.add("West", refreshButton);
              etcPanel.add("East", deleteButton);
              add("North", buttonPanel);
              add("South", etcPanel);
              refreshButton.addActionListener(this);
              deleteButton.addActionListener(this);
          * Pre:          students.dat in current directory
          *                studentList instantiated
          * Post:     studentList has Student objects with names, not images(yet)
          * Purpose:     to set up studentList with student names
         private void readStudentNames(){
              try {
                   FileReader dataInput = new FileReader("students.dat");
                   input = new Scanner(dataInput);
              } catch (FileNotFoundException e) {
                   System.err.println("ERROR:Students.dat file not found");
                   e.printStackTrace();
              studentsList = new RefSortedList();
              while(input.hasNextLine()){
                   String studentName = input.nextLine();
                  studentVar = new Student(studentName);
                   studentsList.add(studentVar);
              System.out.println(studentsList + "");
         }//readStudentNames()
          * Pre:          studentList set up with names
          *                .jpg files are in current directory
          * Post:     buttons set up with images in buttonList and buttonPanel
          * Purpose:     to set up buttons with Student names and images
         private void setUpImages(){
              ImageIcon studentPic;
              Student studentStringPic;
              studentsList.reset();
              buttonList =  new RefUnsortedList();
              buttonPanel = new JPanel(new GridLayout(5,3));
              for (int k = 0; k < studentsList.size(); k++) {
                   studentPic = new ImageIcon(studentVar.toString() + ".jpg");
                   studentStringPic = new Student(studentVar.toString(), studentPic);
                   b = new JButton(studentStringPic.toString(), studentStringPic.getIcon());
                   b.setVerticalTextPosition(AbstractButton.BOTTOM);
                  b.setHorizontalTextPosition(AbstractButton.CENTER);
                   b.addActionListener(this);
                   buttonList.add(b);
                  buttonPanel.add(b);
                   studentsList.getNext();
          * Pre:          buttonList set up
          * Post:     All buttons enabled
          * Purpose:     To enable all buttons in buttonList
         public void refreshImages(){
              for(int i=0;i<buttonList.size();i++){
                   b.setEnabled(true);
                   buttonList.getNext();
         * Pre:     buttonPanel, buttonList set up
         * Post:    disabled buttons removed from buttonPanel
         * Purpose: To delete those students whose buttons are disabled
        private void deleteStudents(){
             for(int k=0; k<buttonList.size();k++){
                  if(!b.isEnabled())
                       buttonPanel.remove(b);
                  buttonList.getNext();
             this.repaint();
         public void actionPerformed(ActionEvent e) {
              JButton b = (JButton) e.getSource();
              if(e.getSource() == deleteButton){
                   deleteStudents();
              else if(e.getSource() == refreshButton){
                   refreshImages();
              else{
                   b.setEnabled(false);
    }Student Class:
    public class Student implements Comparable{
         private String name;
         private Icon icon;
         public Student(String nameT){
              name = nameT;
         public Student(String nameT, Icon iconT){
              name = nameT;
              icon = iconT;
         public int compareTo(Object arg0) {
              if(this.equals(name))
                   return 1;
              else
                   return -1;
         }//compareTo()
         public boolean equals(){
              boolean equalTo = false;
              if(this.equals(name))
                   equalTo = true;
              return equalTo;
         }//equals()
          * Pre: LL is instantiated and filled
          * Post: none
          * Purpose: return the name of the student
         public String toString(){
              return name;
         }//toString()
         public Icon getIcon(){
              return icon;
    }

    I fixed the other things, I just need to fix two more problems and then clean up my code so it looks more professional.
    First problem: When I add the Student variables to the studentsList, they aren't sorted. I think this is because they aren't being read as Strings and so there's no way to compare them. I could just do studentVar.toString(), but then studentsList would be full of Strings and not Students. Any ideas?
          * Pre:          students.dat in current directory
          *                studentList instantiated
          * Post:     studentList has Student objects with names, not images(yet)
          * Purpose:     to set up studentList with student names
         private void readStudentNames(){
              try {
                   FileReader dataInput = new FileReader("students.dat");
                   input = new Scanner(dataInput);
              } catch (FileNotFoundException e) {
                   System.err.println("ERROR:Students.dat file not found");
                   e.printStackTrace();
              studentsList = new RefSortedList();
              while(input.hasNextLine()){
                   String studentName = input.nextLine();
                  studentVar = new Student(studentName);
                   studentsList.add(studentVar);
              System.out.println(studentsList + "");
         }//readStudentNames()Here's the add() method of RefSortedList:
    public void add(Comparable element)
      // Adds element to this list.
        LLObjectNode prevLoc;     // trailing reference
        LLObjectNode location;    // traveling reference
        Comparable listElement;   // current list element being compared     
        boolean moreToSearch;            
        // Set up search for insertion point.
        location = list;
        prevLoc = null;
        moreToSearch = (location != null);
        // Find insertion point.
        while (moreToSearch)
          listElement = (Comparable)location.getInfo();
          if (listElement.compareTo(element) < 0)  // list element < add element
             prevLoc = location;
             location = location.getLink();
             moreToSearch = (location != null);   // stop looking at end of list
          else
            moreToSearch = false;     // list element >= add element
        // Prepare node for insertion.
        LLObjectNode newNode = new LLObjectNode(element);
        // Insert node into list.
        if (prevLoc == null)        
          // Insert as first node.
          newNode.setLink(list);
          list = newNode;
        else
          // Insert elsewhere.
          newNode.setLink(location);
          prevLoc.setLink(newNode);
        numElements++;
      }

  • Need help with Blog, Wiki and Gallery

    Hi Team,
    Need help with Blog, Wiki and Gallery startup. I have newly started visiting forums and quite interested to contribute towards these areas also.
    Please help.
    Thanks,
    Santosh Singh
    Santosh Singh

    Hello Santhosh,
    Blog is for Microsoft employees only. However, you can contribute towards WIKI and GALLERY using the below links.
    http://social.technet.microsoft.com/wiki/
    http://gallery.technet.microsoft.com/

  • Problem with Linked List

    i have make a database with linked list for a School student counselor.
    The to be store is
    student name, ID, Counseling Date, Progress
    In there there will be record for a student and the Date and progress has to be stored for 4-weeks as the counseling is on weekly basis. These data items will be multivalued(what u say in Databases) how i can store this repetitive data in linked list for one student.

    By capsulating the data in objects and adding the objects to a linked list.

  • What's the phone number I should call for help with my iPhone and ihome dock?

    What's the phone number I should call for help with my iPhone and ihome dock?

    http://www.ihomeaudio.com/support/

  • Help with photoshop quitting and AMD graphics

    help with photoshop quitting and AMD graphics
    im not a techy, but it appears i have to do someting with my amd graphics card - this might be why my software is crashing - ive no idea what to do though

    Hi Chris
    I have tried to go on the website, then i tried to download the automatic detect because i wasnt sure which driver i had or needed - but it has just downloaded a load of game software - which i dont want ( i dont think)
    i have find out my laptop has a amd radeon HD 8750M card, but i dont know what im doing! i would hate to mess my computer up as i am in thailand with no one to help me!
    its frustrating as i am paying for CC but cant use it!

  • Help PLEASE with linked list. Inserting a string in the middle of

    I'm trying to insert new strings to a linked list but it seem i cant never insert. the following code has the instructions. What i'm I not doing right? If i try to use the code, the new strings don't go through
    please help someone
    // This method should insert a new node containing the string newString immediately after the first
        // occurrence of the string aString in the list. If aString is not in the list, the method should add a node
        // containing newString to the tail of the list.
        public void insertAfter(String newString, String aString)
            StringLLNode newNode = new StringLLNode();
            newNode.setData(newString);
            //Check if HeadNode == aString
            if (headNode.getData().equalsIgnoreCase(aString))
                headNode = newNode;
            //rest of the nodes
            StringLLNode currNode = headNode;
            while(currNode != null)
                if (currNode.getData().equalsIgnoreCase(aString))
                        newNode.setNext(currNode);
                        //System.out.println("It went THROUGH");
                currNode = currNode.getNext();
            //Last Node
            if (currNode != null)
                newNode.setNext(headNode);
        }

    I have to agree with flounder, go grab a pen and paper and logically work thru the code snippet you posted.
    public void insertAfter(String newString, String aString)
            StringLLNode newNode = new StringLLNode();
            newNode.setData(newString);
            //Check if HeadNode == aString
            if (headNode.getData().equalsIgnoreCase(aString))
                headNode = newNode;
            //rest of the nodes
            StringLLNode currNode = headNode;
            while(currNode != null)
                if (currNode.getData().equalsIgnoreCase(aString))
                        newNode.setNext(currNode);
                        //System.out.println("It went THROUGH");
                currNode = currNode.getNext();
            //Last Node
            if (currNode != null)
                newNode.setNext(headNode);
    }Given a linked list [A-E] we have: A => B => C => D => E. Each Node is referencing the node to it's right, so A references B, D references E etc.
    For example take aString = "A" and newString = "AB". Your code suggests the following:
    1. Create new_node "AB"
    2. if head[A] equals aString[A], TRUE
    2.a head = new_ node
    Now the resulting linkedlist is the following:
    AB => Null
    what happened to the rest of the list?
    Now we go on to your updated example, we result in the following list:
    A => AB => Null
    hmm do you see a pattern here? when inserting a new node we are disregarding any reference to the tail of the list.
    Extending on that idea we have the following pseudo code
    1. if node to be inserted
    1.a new_node.next = list_tail
    1.b current_node.next = new_node
    A => B => C => D => E, where newnode=AA
    AA => B => C => D => E //using 1.a
    A => AA => B => C => D => E //using 1.b
    Mel

  • Report with select list and link to call another report

    Hi,
    I am trying to do 2 reports (REPORT1 and REPORT2).
    The first is a summary report (REPORT1).
    This report will display sales figures for the year. Now, I need to have a select list in the result set that will have 2 options, depending on which option is chosen, I want to call REPORT2 with the select list as a parameter. How can I do this ?
    Let me try to explain what I did.
    I created REPORT1 on Page 100
    SELECT YEAR, sum(YTD_SALES), APEX_ITEM.SELECT_LIST(1,'DEPARTMENT','Department;DEPARTMENT,Division;DIVISION') Drilldown FROM SALES_ANALYSIS WHERE YEAR > 2000
    GROUP BY YEAR ORDER BY YEAR
    I created 2 hidden items namely P100_YEAR and P100_DRILLDOWN
    I also made the column YEAR as a link and specified both P100_YEAR and P100_DRILLDOWN as parameters to be passed.
    Next, I created REPORT2
    SELECT YEAR, DECODE(:P100_DRILLDOWN, 'Department', department, 'Division', Division) dept_div, sum(YTD_SALES) ytd_sales
    FROM SALES_ANALYSIS
    WHERE YEAR = :P100_YEAR
    When I run Report 1, it's fine, when I choose either Department or Division from the Select List and click on the link to call Report 2, report 2 is displayed, but the value being passed for P100_DRILLDOWN is not correct and as a result, I am unable to get correct results for Report 2
    Am I missing something ? Are there any alternate ways to do what I'm doing ?
    Thanks,
    Ashok

    Hi Ashok,
    The link definition will not know the value selected in the list as it is constructed only when the page is being rendered. You would need to create some javascript to handle this. I've done that here: [http://apex.oracle.com/pls/otn/f?p=267:182]
    The link on the EMPNO column has been defined in the HTML Expression setting for the column instead of the Link section. The HTML Expression that I have used is:
    &lt;a href="#" onclick="javascript:doDrilldown('#EMPNO#',this);"&gt;#EMPNO#&lt;/a&gt;And, in the page's HTML Header setting, I have added in:
    &lt;script type="text/javascript"&gt;
    function doDrilldown(empno,group)
    var g;
    var p = group.parentNode;
    while (p.tagName != "TR")
      p = p.parentNode;
    var x = p.getElementsByTagName("SELECT");
    if (x.length &gt; 0)
      g = x[0].value;
    var url = "f?p=&APP_ID.:183:&SESSION.::::P183_EMPNO,P183_GROUP:" + empno + "," + g;
    document.location.href = url;
    &lt;/script&gt;When a link is clicked, the doDrilldown function is called passing in the EMPNO value and the "this" object (which identifies the object triggering the call). The function starts from that object and goes up in the HTML tag tree to the nearest TR tag (the row tag that the link is on) and then finds the first SELECT list item on the row and gets its value. It then constructs a URL using this and the EMPNO value and performs a redirect to the second page (page 183 in this example).
    Andy

Maybe you are looking for

  • Macbook Air Mid 13 TrackPad and Keyboard Stopped working.

    Both trackpad and mouse work when I have to sign into my account; however, once I'm on my windows screen both stop working. It tries and searches for bluetooth keyboard and mouse. I don't know how else to fix this issue. Please help I have tried all

  • Mac pro 5,1 RAM Upgrade

    I am planning to give my Mac Pro (Mid 2010) another RAM upgrade. As the official Kingston/Crucial DIMMs do not include 16GB DIMMs, I think of choosing Kingston Value RAM: ECC Registered (3x, 16GB, DDR3-1600, DIMM 240). Has anyone here in the forum tr

  • G5 won't power on but light is stuck on!

    Hi Today the power in my flat was turned off at the mains after there was a flood in my buildinbg - this happened while my G5 was on. When the power came back on at the mains, I found that the G5 white power light was on at the front, but nothing els

  • Do I need to be accredited to use the SAP SDK?

    Hello, I am software developer working for a small company that uses SAP BO 2005A in the finance and sales department. I recently discovered the SAP SDK installed on our machines (server and PC's), and after some research and looking at people's samp

  • Unable to assign a place

    I am not able to click into the "Assign a Place" box anymore. I used to be able to double click and edit the location. Now I cannot. Nothing works. What is wrong with my iPhoto?