What is wrong with my delete method in my binary tree

code..okay so somehow everytime I delete a number that exist it says it has been deleted later when..I display the tree the node wasn' t really deleted at all here is the code..
     public boolean delete(int numbers)
          Node now = rootOrigin;
          Node ancestor = rootOrigin;
          boolean isLeftChild = true;
          if(find(numbers)!= null)
               if((now.LeftChildOfMine == null)&&(now.RightChildOfMine == null))
                    if(now == rootOrigin)
                         rootOrigin = null;
                    else if(isLeftChild)
                         ancestor.LeftChildOfMine = null;
                    else
                         ancestor.RightChildOfMine = null;
               else if((now.LeftChildOfMine != null)&&(now.RightChildOfMine == null))
                    if(now==rootOrigin)
                         now = now.LeftChildOfMine;
                    else if(isLeftChild)
                         ancestor.LeftChildOfMine = now.LeftChildOfMine;
                    else
                         ancestor.RightChildOfMine = now.LeftChildOfMine;
               else if((now.LeftChildOfMine == null)&&(now.RightChildOfMine != null))
                    if(now==rootOrigin)
                         rootOrigin = now.RightChildOfMine;
                    else if(isLeftChild)
                         //ancestor.LeftChildOfMine = now.RightChildOfMine;
                         ancestor.RightChildOfMine = now.LeftChildOfMine;
                    else
                         //ancestor.RightChildOfMine = now.RightChildOfMine;
                         ancestor.LeftChildOfMine = now.RightChildOfMine;
               else if((now.LeftChildOfMine != null)&&(now.RightChildOfMine != null))
                    //get successor of node to delete(current)
                    Node successor = getSuccessor(now);
                    //connect parent of current to successor instead
                    if (now == rootOrigin)
                         rootOrigin = successor;
                    else if(isLeftChild)
                         ancestor.LeftChildOfMine = successor;
                    else
                         ancestor.RightChildOfMine = successor; //connect successor to current's left child
                    successor.LeftChildOfMine = now.LeftChildOfMine;
          return true;     
          else
               return false;
     }Also here is the method that finds the successor of the node that will replace the node that i want to delete
     private Node getSuccessor(Node delNode)
          Node successorParent = delNode;
          Node successor = delNode ;
          Node now = delNode.RightChildOfMine;
          while(now != null)
               successorParent = successor;
               successor = now;
               now = now.LeftChildOfMine;
          if(successor != delNode.RightChildOfMine)
               successorParent.LeftChildOfMine = successor.RightChildOfMine;
               successor.RightChildOfMine = delNode.RightChildOfMine;
               return successor;
     }Okay also a while ago when I focused on traversing(nodes kept displaying more than once) my prof. said the problem was in my insertion method.
It mayber the insertion method's fault again
     public void insert(int numbers)
          Node newNode = new Node(numbers);
          if(rootOrigin == null)     
               rootOrigin = newNode;     // newNode will be the root of the tree
          else
               Node current = rootOrigin;
               Node parent;
               while(true)
                    parent = current;
                    if(numbers < current.numbers)
                         current = current.LeftChildOfMine;
                         if(current == null)
                              parent.LeftChildOfMine = newNode;
                              return;
                    else
                         current = current.RightChildOfMine;
                         if(current == null)
                              parent.RightChildOfMine = newNode;
                              return;
     }

DaDonYordel wrote:
          if(find(numbers)!= null)
               if((now.LeftChildOfMine == null)&&(now.RightChildOfMine == null))Shouldn't you be assigning the result of the find() to now?

Similar Messages

  • What is wrong with BTree Deletion

    Hi
    I am trying to delete nodes from BTree . Can anyone please tell me what is wrong with it . It delets the wrong node ???
    public BTreeA delete(BTreeA node ) {
    // use integer in order to parseInt string ("StId") and then compare the values
         int x , y ,z ;
         if ( root.counter < 1 ){
              ptemp = root ;
              root.counter++;
    x = Integer.parseInt(node.StId );
    y = Integer.parseInt(ptemp.StId);
    if( root != null ) { // descend tree to find parent
    if ( x < y ){
    ptemp = root.left ;
    root.left = delete(root.left ) ;
    } else
    // or else move right
    if ( x > y ){
    ptemp = root.right ;
    root.right = delete (root.right ); // else it must be greater
    }else{       
    // print
    System.out.println();
    System.out.println( "Student ID "+ptemp.StId +" is in the tree!");
    System.out.println ("Student name is : "+ptemp.StName);
    System.out.println ("Student Address is : "+ptemp.StAddress );
    System.out.println( "***OOOOO***oooo***OOOO***");
    if( root.left == null && root.right == null ){
    root = null ;
    } else
    if(root.left != null && root.right == null){
    root = root.left ;
    } else
    if(root.right != null && root.left == null ){
    root = root.right ;
    } else {
    if(root.right.left == null){
    root.right.left = root.left ;
    root.right = root ;
    }else { 
    BTreeA a,b = root.right ;
    while ( b.left.left != null )
         b = b.left ;
         a= b.left ;
         b.left = a.right ;
         a.left = root.left ;
         a.right = root.right ;
         root = a ;
    return this ;
    }//end of method
    // main method
    BTreeA node = new BTreeA () ;
    node.StId = "2";
    node.StName = "Fiona";
    node.StAddress = " Waterford " ;
    root.delete (node);

    Hi
    I am trying to delete nodes from BTree . Can anyone
    please tell me what is wrong with it . It delets the
    wrong node ???
    public BTreeA delete(BTreeA node ) {
    // use integer in order to parseInt string ("StId")
    and then compare the values
         int x , y ,z ;
         if ( root.counter < 1 ){
              ptemp = root ;
              root.counter++;
    x = Integer.parseInt(node.StId );
    y = Integer.parseInt(ptemp.StId);
    if( root != null ) { // descend tree to find
    nd parent
    if ( x < y ){
    ptemp = root.left ;
    root.left = delete(root.left ) ;
    } else
    // or else move right
    if ( x > y ){
    ptemp = root.right ;
    root.right = delete (root.right ); // else it must
    st be greater
    }else{       
    // print
    System.out.println();
    System.out.println( "Student ID "+ptemp.StId +" is
    s in the tree!");
    System.out.println ("Student name is :
    : "+ptemp.StName);
    System.out.println ("Student Address is :
    : "+ptemp.StAddress );
    System.out.println( "***OOOOO***oooo***OOOO***");
    if( root.left == null && root.right == null ){
    root = null ;
    } else
    if(root.left != null && root.right == null){
    root = root.left ;
    } else
    if(root.right != null && root.left == null ){
    root = root.right ;
    } else {
    if(root.right.left == null){
    root.right.left = root.left ;
    root.right = root ;
    }else { 
    BTreeA a,b = root.right ;
    while ( b.left.left != null )
         b = b.left ;
         a= b.left ;
         b.left = a.right ;
         a.left = root.left ;
         a.right = root.right ;
         root = a ;
    return this ;
    }//end of method
    // main method
    BTreeA node = new BTreeA () ;
    node.StId = "2";
    node.StName = "Fiona";
    node.StAddress = " Waterford " ;
    root.delete (node);

  • What's wrong with this simple method

    i'm having compile troubles with this simple method, and i think it's got to be something in my syntax.
    public String setTime()
    String timeString = new String("The time is " + getHours() + ":" + getMinutes() + ":" + getSeconds() + " " + getIsAM());
    return timeString;
    this simple method calls the get methods for hours, minutes, seconds, and isAM. the compiler tells me i need another ) right before getSeconds(), but i don't believe it. i know this is a simple one, but i could use the advice.
    thanks.

    Hi,
    I was able to compile this method , it gave no error

  • What's wrong with this delete?

    String query = "Delete from K9Manager where intakeno = ?";
         PreparedStatement pstmt = db.createPreparedStatement(query);
         pstmt.setString(1, request.getParameter("f_Page").trim());
         pstmt.executeUpdate();
         out.println("+query+");
    No matter what I always get this error. I don't understand it.. any hints?
    Unable to query K9Manager table

    Which database you are using? The most common problem may be the user wich is trying to delete the record has no right to delete a record.

  • What's wrong with this save method

    It won't let me add any new records to my database. Please help
         String sql = "insert into Sold_Vehicles(Serial_Number, Owner_Name, Make, Address, Model, Phone_Number, Year, Drivers_License_Number, Kilometers, Date_Purchased, Transmission, Warranty_Policy_Number, MRSP, Seller_Name, Sold_Price, Commission, Engine_Size, Method_of_Payment, Plate_Number, Body_Style, Year_received, Rims, Color, Warranty, Previous_Owner, Comments, Air_Conditioning, Power_Brakes, Power_Steering, Power_Locks, Power_Windows, Leather_Interior, CD_Player, Cruise, Tilt_Steering, Model_Year, Cost, Negotiable_Amount, Condition) values ('" + t47.getText() + "', '" + t16.getText() + "', '" + t17.getText() + "', '" + t18.getText() + "', '" + t19.getText() + "', '" + t20.getText() + "', '" + t21.getText() + "', '" + t22.getText() + "', '" + t23.getText() + "', '" + t24.getText() + "', '" + t25.getText() + "', '" + t26.getText() + "', " + t27.getText() + ", '" + t28.getText() + "', " + t29.getText() + ", " + t30.getText()+ ", '" + t31.getText() + "', '" + t32.getText() + "', '" + t33.getText() + "', '" + t34.getText() + "', '" + t35.getText() + "', '" + t36.getText() + "', '" + t37.getText() + "', '" + t38.getText() + "', '" + t39.getText() + "', '" + t40.getText() + "', " + temp + ", " + temp1 + ", " + temp2 + ", " + temp3 + ", " + temp4 + ", " + temp5 + ", " + temp6 + ", " + temp7 + ", " + temp8 + ", '" + t41.getText() + "', " + t42.getText() + ", " + t43.getText() + ", '" + t44.getText() + "')";
         st = conn.createStatement();
         int z = st.executeUpdate(sql);
         displayNext1();
         }catch(SQLException sql) {System.out.println("me");}
    public void addrecord() // add
         t16.setEnabled(true);
         t16.setText("");
         t17.setEnabled(true);
    t17.setText("");
    t18.setEnabled(true);
    t18.setText("");
    t19.setEnabled(true);
    t19.setText("");
    t20.setEnabled(true);
    t20.setText("");
    t21.setEnabled(true);
    t21.setText("");
    t22.setEnabled(true);
    t22.setText("");
    t23.setEnabled(true);
    t23.setText("");
    t24.setEnabled(true);
    t24.setText("");
    t25.setEnabled(true);
    t25.setText("");
    t26.setEnabled(true);
    t26.setText("");
    t27.setEnabled(true);
    t27.setText("");
    t28.setEnabled(true);
    t28.setText("");
    t29.setEnabled(true);
    t29.setText("");
    t30.setEnabled(true);
    t30.setText("");
    t31.setEnabled(true);
    t31.setText("");
    t32.setEnabled(true);
    t32.setText("");
    t33.setEnabled(true);
    t33.setText("");
    t34.setEnabled(true);
    t34.setText("");
    t35.setEnabled(true);
    t35.setText("");
    t36.setEnabled(true);
    t36.setText("");
    t37.setEnabled(true);
    t37.setText("");
    t38.setEnabled(true);
    t38.setText("");
    t39.setEnabled(true);
    t39.setText("");
    t40.setEnabled(true);
    t40.setText("");
    t41.setEnabled(true);
    t41.setText("");
    t42.setEnabled(true);
    t42.setText("");
    t43.setEnabled(true);
    t43.setText("");
    t44.setEnabled(true);
    t44.setText("");
    t47.setEnabled(true);
    t47.setText("");
    var = 2;
    t47.requestFocus();
    }

    It's my first program, I'm just out of school, must
    you be so negative and criticize it, I'm only looking
    for a little help. You posted your code in a public, unmoderated forum. Don't expect every response you get to be something you want ot hear.
    So printing the stacktrace
    (e.printStackTrace()) in the catch clause should help
    solve my problem.Well, it won't solve your problem, per se. What it will do is help you identify where and why you're generating an error. Swallowing exceptions (i.e., empty catch blocks) are rarely a good idea. As a beginner, you should make it a practice to always print a stack trace at the very least.
    The other advice you received is worthwhile as well; namely, look into PreparedStatement and (for the love of all that's holy) name your variables something meaningful. Check these out as well: Code Conventions for the Java&#153; Programming Language.
    Good luck!

  • I have just deleted an app call Wattpad and I want to download it again but it always says that I need to retry downloading it. I have tried restart a few times but nothing seems to happen. What's wrong with my phone? If I reset my phone will my pictures

    I have just deleted an app call Wattpad and I want to download it again but it always says that I need to retry downloading it. I have tried restart a few times but nothing seems to happen. What's wrong with my phone? If I reset my phone will my pictures

    Hello there, SamanthaYikwai.
    The following Knowledge Base article offers up some basic steps to try for reinstalling an app:
    iOS: An app you installed unexpectedly quits, stops responding, or won’t open.
    http://support.apple.com/kb/ts1702
    Reinstall the app
    Remove the app from your device and reinstall it. Remember that deleting an app also deletes its data.
    Delete the app.
    Press the Home button.
    Go to the App Store and download the app again.
    Wait for the app to download, then open it from the Home screen.
    If the download stops, you can resume it.
    If the issue persists, then you may want to try and sync the application to your iOS device using  your computer by following the information in this article, under the section "Download previous purchases on Mac or PC":
    Download past purchases
    http://support.apple.com/kb/HT2519
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • What's wrong with my code? compliation error

    There is a compilation error in my program
    but i follow others sample prog. to do, but i can't do it
    Please help me, thanks!!!
    private int selectedRow, selectedCol;
    final JTable table = new JTable(new MyTableModel());
    public temp() {     
    super(new GridLayout(1, 0));                         
    table.setPreferredScrollableViewportSize(new Dimension(600, 200));     
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);     
    ListSelectionModel rowSM = table.getSelectionModel();
    rowSM.addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
         //Ignore extra messages.
    if (e.getValueIsAdjusting()) return;
    ListSelectionModel lsm = (ListSelectionModel)e.getSource();
    if (lsm.isSelectionEmpty()) {
         System.out.println("No rows are selected.");
    else {
         selectedRow = lsm.getMinSelectionIndex();
    System.out.println("Row " + selectedRow+ " is now selected.");
    JScrollPane scrollPane = new JScrollPane(table);
    add(scrollPane);
    createPopupMenu();
    public void createPopupMenu() {       
    //Create the popup menu.
    JPopupMenu popup = new JPopupMenu();
    // display item
    JMenuItem menuItem = new JMenuItem("Delete selected");
    popup.add(menuItem);
    menuItem.addActionListener(new ActionListener(){
         public void actionPerformed(ActionEvent e){
              System.out.println("Display selected.");
              System.out.println("ClientID: "+table.getValueAt(selectedRow,0));
              int index = table.getSelectedColumn();
              table.removeRow(index);     <-------------------------------compliation error     
         }}); //what's wrong with my code? can anyone tell
    //me what careless mistake i made?
    MouseListener popupListener = new PopupListener(popup);
    table.addMouseListener(popupListener);
    public class MyTableModel extends AbstractTableModel {
    private String[] columnNames = { "ClientID", "Name", "Administrator" };
    private Vector data = new Vector();
    class Row{
         public Row(String c, String n, String a){
              clientid = c;
              name = n;
              admin = a;
         private String clientid;
         private String name;
         private String admin;
    public MyTableModel(){}
    public void removeRow(int r) {    
         data.removeElementAt(r);
         fireTableChanged(null);
    public int getColumnCount() {
    return columnNames.length;
    public int getRowCount() {
    return data.size();
    public String getColumnName(int col) {
    return columnNames[col];
    public Object getValueAt(int row, int col) {
         return "";
    public boolean isCellEditable(int row, int col) {   
    return false;
    public void setValueAt(Object value, int row, int col) {}
    }

    Inside your table model you use a Vector to hold your data. Create a method on your table model
    public void removeRow(int rowIndex)
        data.remove(rowIndex); // Remove the row from the vector
        fireTableRowDeleted(rowIndex, rowIndex); // Inform the table that the rwo has gone
    [/data]
    In the class that from which you wish to call the above you will need to add a reference to your table model.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • C# - What's wrong with a table called JOBS? :(

    Post Author: Gee
    CA Forum: .NET
    Hi
    I've just moved up to .NET 2005. and am having a big problem right now with one report in particular.
    The report uses an Oracle table called "JOBS". It worked just fine in .NET 2003. Now though, it comes up with the dreaded field name not known error.
    So, I tried to just do a completely new report with just ONE field from the JOBS table on it. It doesn't want to know!
    I then copied (so it was IDENTICAL) the table structure and data to a new one called "JOBSTEST". The simple report worked (once I'd changed it to use the JOBSTEST fields of course)
    I deleted the original JOBS table, copied a new JOBS table from the JOBSTEST table and... it didn't work again!
    So, what's wrong with having a table called "JOBS"? Because that seems to be the problem!
    Oh... it works ok on the development machine. Just not any other. ALL other reports work fine!
    Thank you so much for your time in helping me

    Post Author: Gee
    CA Forum: .NET
    Hi
    I've just moved up to .NET 2005. and am having a big problem right now with one report in particular.
    The report uses an Oracle table called "JOBS". It worked just fine in .NET 2003. Now though, it comes up with the dreaded field name not known error.
    So, I tried to just do a completely new report with just ONE field from the JOBS table on it. It doesn't want to know!
    I then copied (so it was IDENTICAL) the table structure and data to a new one called "JOBSTEST". The simple report worked (once I'd changed it to use the JOBSTEST fields of course)
    I deleted the original JOBS table, copied a new JOBS table from the JOBSTEST table and... it didn't work again!
    So, what's wrong with having a table called "JOBS"? Because that seems to be the problem!
    Oh... it works ok on the development machine. Just not any other. ALL other reports work fine!
    Thank you so much for your time in helping me

  • What is wrong in this Quicksort method??

    Please go through the program and tell me what is wrong with the method Quicksort? Thanx.
    The program:
    public class Main {
    * @param args the command line arguments
    public static void main(String[] args) {
    int[] unsorted = {9,5,6,1,3,8,9,7,5,3,5,3,13};
    unsorted = Quicksort(unsorted,unsorted.length/2,unsorted.length-1);
    for(int i=0;i<unsorted.length;i++)
    System.out.print(unsorted[i]+" ");
    public static int[] Quicksort(int[] input, int pivot, int end)
    if(pivot>0)
    int[] right =new int[pivot-0];
    int[] left =new int[end-pivot];
    int[] sortedArray = new int[1000];
    int lft=0,rht=0;
    for(int i=0;i<end;i++)
    if(input[pivot]<input)
    right[rht++]=input[i];
    else if(input[pivot]>input[i])
    left[lft++]=input[i];
    left = Quicksort(left,lft/2,lft);
    right = Quicksort(right,rht/2,rht);
    int i;
    for(i=0;i<lft;i++)
    sortedArray[i]=left[i];
    i++;
    sortedArray[i]=input[pivot];
    for(int j=0;j<rht;j++)
    sortedArray[j+i]=right[j];
    return sortedArray;
    else
    return null;
    the errors:
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 6
    at qsort.Main.Quicksort(Main.java:39)
    at qsort.Main.main(Main.java:19)
    Java Result: 1
    39: left[lft++]=input[i];
    19: unsorted = Quicksort(unsorted,unsorted.length/2,unsorted.length-1);

    When posting code, make sure you use the CODE tags to preserve formatting.
    But I can tell you right now that your problem is exactly what the error message tells you it is. Step through to figure out why that happens, something is wrong in your logic.

  • I can't figure out what's wrong with this code

    First i want this program to allow me to enter a number with the EasyReader class and depending on the number entered it will show that specific line of this peom:
    One two buckle your shoe
    Three four shut the door
    Five six pick up sticks
    Seven eight lay them straight
    Nine ten this is the end.
    The error message i got was an illegal start of expression. I can't figure out why it is giving me this error because i have if (n = 1) || (n = 2) statements. My code is:
    public class PoemSeventeen
    public static void main(String[] args)
    EasyReader console = new EasyReader();
    System.out.println("Enter a number for the poem (0 to quit): ");
    int n = console.readInt();
    if (n = 1) || (n = 2)
    System.out.println("One, two, buckle your shoe");
    else if (n = 3) || (n = 4)
    System.out.println("Three, four, shut the door");
    else if (n = 5) || (n = 6)
    System.out.println("Five, six, pick up sticks");
    else if (n = 7) || (n = 8)
    System.out.println("Seven, eight, lay them straight");
    else if (n = 9) || (n = 10)
    System.out.println("Nine, ten, this is the end");
    else if (n = 0)
    System.out.println("You may exit now");
    else
    System.out.println("Put in a number between 0 and 10");
    I messed around with a few other thing because i had some weird errors before but now i have narrowed it down to just this 1 error.
    The EasyReader class code:
    // package com.skylit.io;
    import java.io.*;
    * @author Gary Litvin
    * @version 1.2, 5/30/02
    * Written as part of
    * <i>Java Methods: An Introduction to Object-Oriented Programming</i>
    * (Skylight Publishing 2001, ISBN 0-9654853-7-4)
    * and
    * <i>Java Methods AB: Data Structures</i>
    * (Skylight Publishing 2003, ISBN 0-9654853-1-5)
    * EasyReader provides simple methods for reading the console and
    * for opening and reading text files. All exceptions are handled
    * inside the class and are hidden from the user.
    * <xmp>
    * Example:
    * =======
    * EasyReader console = new EasyReader();
    * System.out.print("Enter input file name: ");
    * String fileName = console.readLine();
    * EasyReader inFile = new EasyReader(fileName);
    * if (inFile.bad())
    * System.err.println("Can't open " + fileName);
    * System.exit(1);
    * String firstLine = inFile.readLine();
    * if (!inFile.eof()) // or: if (firstLine != null)
    * System.out.println("The first line is : " + firstLine);
    * System.out.print("Enter the maximum number of integers to read: ");
    * int maxCount = console.readInt();
    * int k, count = 0;
    * while (count < maxCount && !inFile.eof())
    * k = inFile.readInt();
    * if (!inFile.eof())
    * // process or store this number
    * count++;
    * inFile.close(); // optional
    * System.out.println(count + " numbers read");
    * </xmp>
    public class EasyReader
    protected String myFileName;
    protected BufferedReader myInFile;
    protected int myErrorFlags = 0;
    protected static final int OPENERROR = 0x0001;
    protected static final int CLOSEERROR = 0x0002;
    protected static final int READERROR = 0x0004;
    protected static final int EOF = 0x0100;
    * Constructor. Prepares console (System.in) for reading
    public EasyReader()
    myFileName = null;
    myErrorFlags = 0;
    myInFile = new BufferedReader(
    new InputStreamReader(System.in), 128);
    * Constructor. opens a file for reading
    * @param fileName the name or pathname of the file
    public EasyReader(String fileName)
    myFileName = fileName;
    myErrorFlags = 0;
    try
    myInFile = new BufferedReader(new FileReader(fileName), 1024);
    catch (FileNotFoundException e)
    myErrorFlags |= OPENERROR;
    myFileName = null;
    * Closes the file
    public void close()
    if (myFileName == null)
    return;
    try
    myInFile.close();
    catch (IOException e)
    System.err.println("Error closing " + myFileName + "\n");
    myErrorFlags |= CLOSEERROR;
    * Checks the status of the file
    * @return true if en error occurred opening or reading the file,
    * false otherwise
    public boolean bad()
    return myErrorFlags != 0;
    * Checks the EOF status of the file
    * @return true if EOF was encountered in the previous read
    * operation, false otherwise
    public boolean eof()
    return (myErrorFlags & EOF) != 0;
    private boolean ready() throws IOException
    return myFileName == null || myInFile.ready();
    * Reads the next character from a file (any character including
    * a space or a newline character).
    * @return character read or <code>null</code> character
    * (Unicode 0) if trying to read beyond the EOF
    public char readChar()
    char ch = '\u0000';
    try
    if (ready())
    ch = (char)myInFile.read();
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    if (ch == '\u0000')
    myErrorFlags |= EOF;
    return ch;
    * Reads from the current position in the file up to and including
    * the next newline character. The newline character is thrown away
    * @return the read string (excluding the newline character) or
    * null if trying to read beyond the EOF
    public String readLine()
    String s = null;
    try
    s = myInFile.readLine();
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    if (s == null)
    myErrorFlags |= EOF;
    return s;
    * Skips whitespace and reads the next word (a string of consecutive
    * non-whitespace characters (up to but excluding the next space,
    * newline, etc.)
    * @return the read string or null if trying to read beyond the EOF
    public String readWord()
    StringBuffer buffer = new StringBuffer(128);
    char ch = ' ';
    int count = 0;
    String s = null;
    try
    while (ready() && Character.isWhitespace(ch))
    ch = (char)myInFile.read();
    while (ready() && !Character.isWhitespace(ch))
    count++;
    buffer.append(ch);
    myInFile.mark(1);
    ch = (char)myInFile.read();
    if (count > 0)
    myInFile.reset();
    s = buffer.toString();
    else
    myErrorFlags |= EOF;
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    return s;
    * Reads the next integer (without validating its format)
    * @return the integer read or 0 if trying to read beyond the EOF
    public int readInt()
    String s = readWord();
    if (s != null)
    return Integer.parseInt(s);
    else
    return 0;
    * Reads the next double (without validating its format)
    * @return the number read or 0 if trying to read beyond the EOF
    public double readDouble()
    String s = readWord();
    if (s != null)
    return Double.parseDouble(s);
    // in Java 1, use: return Double.valueOf(s).doubleValue();
    else
    return 0.0;
    Can anybody please tell me what's wrong with this code? Thanks

    String[] message = {
        "One, two, buckle your shoe",
        "One, two, buckle your shoe",
        "Three, four, shut the door",
        "Three, four, shut the door",
        "Five, six, pick up sticks",
        "Five, six, pick up sticks",
        "Seven, eight, lay them straight",
        "Seven, eight, lay them straight",
        "Nine, ten, this is the end",
        "Nine, ten, this is the end"
    if(n>0)
        System.out.println(message[n]);
    else
        System.exit(0);

  • What is wrong with as3

    this is not a question about 'how i do X'. is rather a 'discussion' (flame or whatever, but to defend or argue about aspects, not people) about 'what is wrong with as3' and what aspects whould be taken into consideration for updates. right now i am using as3, and since i paid for this license, i choose this tool over some alternatives and i am using it to do stuff for other people who pay me to do it, i think it can be helpful for all of us if some actions are started in the right direction. i have already posted about 'all people in adobe are dumbasses that do not know how to make a scripting tool and are messing up my work', but i was pissed at the time (i still am pissed) but i believe this is not the right aproach. instead, if this goes to the right people in adobe, we all may get something in the future, like better and easier todo apps and web presentations.
    pre: not only about the as3 specification, but COMPLY with the specification that you set. for example, some time ago there were problems with matrix transforms. this was corrected later with a patch. but this means it is not even doing what is is supposed to do
    1. scriptable masks and movement, sprites and child sprites: there is a sprite with a mask, the mask is a shape drawn via script, something like
    somemask=new shape();
    somemask.graphics.beginfill();
    (...etc)
    somesprite.mask=somemask;
    just like that. now add some child sprites to 'somesprite', and make 'somesprite' move, scale and rotate. there you will have something like a kaleidoscope, but not what you expected to do with your script. as the child sprites move in the parent mask, you will see that the child sprites appear or dissapear kind of randomly, and if the child sprites are textfields, it may be that the text is rendered outside the mask, or partially rendered outside the mask (as in only part of the text), rendered with the wrongf rotation or in the wrong place. some child sprites are clipped correctly, some dissapear totally when only a part should dissapear (clipped) etc.
    way around: have not tried it yet, but i have the impression that bitmaps have different criteria for clipping, so i am thinking of trying this: appli an empty filter (a filter with params so it does not have any effect on the sprite or in the textfield) so the sprite is rendered as bitmap before doing anything else with it. as i said, i have not done it yet, but it may be a way around this problem, to avoid all this inconsistency with clipping
    1-b. inconsistency between hierarchy and coordinates, specially masks: you apply a mask to a sprite, yet the sprite has a set of coordinates (so 'x' in the sprite means an x relative to its container), yet the mask applied to the very same sprite, as another reference as reference for coordinates (like the stage)
    2. painting via script: in any other languaje, in any other situation, something like:
    beginFill(params);
    (...stuff 1)
    endFill();
    beginFill(params);
    (...stuff 2)
    endFill();
    (...etc)
    means: render region of block 1, then render region of block 2 etc, and no matter what, it should be consistent, since there is noplace for ambiguity. if you read it, you may think what that means, even if you dont run it you may have an idea of the picture you want to draw, but not with as3. as3 somehow manages to screw something that simple, and mixes all the blocks, and somehow uses the boundaries of one block as boundaries for other block. is like all blocks are dumped into whatever, and then uses all lines defined into it as boundaries for a unique block. it changes all boundaries and generates inconsistency between what is shown and redraw regions of the resulting picture, like lines that go to the end of the screen and then dont go away in the next frames, even tough the beginfill endfill block should prevent it
    3. event flow: i dont know what was the policy behind as3 event flow design. it is in no way similar or an extension to previous event flow, neither with any event flow in any other plattform. i dont know how most people start with as3; in my case, i unpacked, installed and when i tried to do something with what i already knew i could not, so i started reading the as3 docs, and since is like 800 pages long, i just read the basics and the rest i would 'wing it'. in the part of the event flow, there was something about bubbling and stuff, it was not clear at all and when i tried to do what is was said in the documentation (like preventing events to 'bubble', as is called in the documentation), i could not see any effect but i could see it was a mess. flash is not the only thing out there to work with pictures or to work with mouse events, but is the only one that deals with things like 'target' and 'currentTarget'. my first experience on needing this was when i was dealing with my own event handlers (so the only thing that had control over mouse was the stage, and i would admin everything via script). there were events generated everywhere, the stage got events that were not genrated directly over the stage, but got there not with stage coordinates but the coordinates relative to the sprite that generated the event. so if i hover the mopuse over the stage, and the stage has some things on it how does it work? i get multiple event calls, like it was hovering multiple times over the stage in a single frame, but in each call with different coordinates? and what if i set all child sprites as mouseenabled=false or compare like 'if (event.target != event.currenttarget)', what if i move the mouse over a child, does it prevent the move mouse event at all? or does it filter only the event call with only stage coordinates? in my case, every time i move over another clip (with mouseenabled = true), the stage gets it as 'mouse up', even tough there was never a mouse release, what the hell? do even the people at adobe know how to handle events with their own tool when they require it? why does an event 'bubble' when i have not specifically tell it to do it? mi thought is that this event flow was very poorly conceived, and tough the intention may have been that there were different cases and it shopuld cover all cases, they actually introduced new problems that were not present in traditional ways to handle it, and it is neither the easier way to handle things, and this way, a very simple problem turns into a very ugly thing because it must handle things that were not neccesary to handle, or were implicit in other situations.
    4. legacy: since as3, all interaction is different, and if you want to do things in the new plattform, using the new features, what you already knew just goes to the garbage can. when a new tool arrives, it should be an extension to previous tools (which is a reason to update instead of just buying a new tool from a different vendor). if everything i had or knew just means nothing from now on, then i can not say 'i know flash script', and my previous knowledge gives me no advantage when aproaching the new version. as3 is a new aproach that requires doc reading and stuff, even if you knew something about previous as specifications or other oo languajes. if you decide to change things from now on, like the things mentioned in this post, instead of just throwing away everything the users alerady knew about the tool, do like in java releases, they mark some things as 'deprecated', they keep working as they should, give a warning, but also a message saying this feature is deprecated, we suggest you use this library instead.
    5. lack of previous functionality: if you 'update' something, it meand all previos functionality is still there (probably improved, but not with bugs if it was working fine), plus something else. now it seems backwards, there are some things that could be done in previous versions but not in this one, like 'duplicatemovieclip'
    6. inconsistency with scripting/programming paradigms: (ok, fancy work, but fits perfectly here): as3 proposed ways to handle things, but the people who designed it got 'too creative', and they did something that is not consistent neither with previous versions of as or with other languajes. the documentations is full of things like 'it looks like x languaje or languaje family, but instead of using XXX word, you must use YYY'. great, what is this? namespaces 'work like', but 'differently' for example from java, .net, .c. its got the idea that a namespace means a grouped functionality but there are rules about where should be placed the file (ok, java has this also, .net takes care of it automatically if all files are registered in the project), but what you got is a mess that 'if you know other languajes you got the general idea, but nonetheless, even if you knew this or previosu versions of as, you still have to read whatever we decided arbitrarily just to be different'. namespaces, event handling, vars definition which is not like previous scripting neither like fully typed languajes.. is just a mess.
    7. lack of scripting and graphics integration: unlike flash and adobe tools that just got on the graphics side leaving all the scripting integratuion apart, most tools from other vendors integrate very well interacton with what is on the screen. the script editor: very poor. autocompletion? a drop down list that does not heklp at all, appears in the wrong places, and when you need it to go, it does not go (so if i want to move away from the uncalled drop down list, i have to click somewhere else, making developement slowewr instead of helping, so the drop down list does not capture all events when i dont want to). in other ides you double click somewhere and it will go to the part of code relevant to that event or whatever. for example microsoft tools, ok i am antimicrosoft, and one of the reasons was that when windows 95 got to market proposing itself as the ONLY pc os you could use if you wanted to keep useing the apps you already had, it was a lousy product full of flaws but you had to keep using it because you had no choice. what is so different from what is happening with flash just now? yet the ide of c# is awesome, works very well and seems reliable.
    adobe people: not all user are designers that just make pretty pictures. if it is not intended for scripting then why is it there. and if there are corrections to be done, they should patch all versions, not only the last one. previous version users also paid for their versions.

    Well, there is no point in arguing.
    I personally believe AS3 does exactly what it promises to do within limits (read: reasonable limits) of ECMA type of language. And sometimes it doesn’t do what we expect it to for it cannot possibly emulate everyone’s thinking process. The task, I guess, is to learn to think in terms of AS3 – not to try to make AS3 think like us. No language covers all the grounds. And no, it is not Java - with no negative or positive connotation. It is what it is. Period. I just hope that AS5 will be more Java like.
    You are right about the fact that it is not necessary to know all the aspects of language in order to perform the majority of tasks. But it is paramount to have a clear idea about such fundamental concepts as display list model and events. For instance, depth swap has no meaning in terms of AS3 because display list object stacking is controlled automatically and there is no need for all these jumping through hoops one has to perform in order to control depth in AS2. There no more gaps in depths and one always know where to find things.
    Similarly, there is no point in having duplicateMovieClip method. More conventional OOP ways of object instantiation accomplishes just that and much more. Just because OOP object instantiation needs to be learned doesn’t mean past hacks have place in modern times. duplicateMovieClip is a horse carriage standing next to SUV. What one should choose to travel?
    Events are implemented to the tee in the context of ECMA specifications. I consider Events model as very solid, it works great (exactly as expected) and never failed me. True, it takes time to get used to it. But what doesn’t?
    By the way, speaking about events, contrary to believe in Adobe’s inconsideration to their following. Events are implemented with weakly reference set to false although it would be better to have it set to true. I think this is because there are smart and considerate people out there who knew how difficult it would be for programming novices to deal with lost listeners.
    I think AS3 is million times better than AS2. And one of the reasons it came out this way is that Adobe made a very brave and wise decision to break totally loose from AS2’s inherent crap. They have created a totally new and very solid language. If they had tried to make it backward compatible – it would be a huge screw up, similar to how our friends at Microsoft are prostituting VB and VBA – extremely irritating approach IMHO.
    Also, Flash legacy issues shouldn’t be overlooked. Flash did not start as a platform for programmers. Entire timeline concept in many ways is not compatible with the best OOP practices and advancements. I think for anyone who is used to writing classes the very fact of coding on timeline sounds awkward. It feels like a hack (and AS2 IS a pile of hacks) – the same things can be nicely packaged into classes and scale indefinitely. As such I wouldn’t expect Adobe to waste time on hacking timeline concept issues by making smarter editor. They have made a new one – FlexBuilder – instead. Serious programmers realize very soon that Flash IDE is not for developing industrial strength applications anyway. So, why bother with channeling great minds into polishing path to the dead end?
    I would like to state that all this is coming form a person who knew Flash when there was no AS at all. And I applaud every new generation of this wonderful tool.
    I believe Adobe does a great job making transition from timeline paradigm to total OOP venue as smooth as possible. And no, they don’t leave their devoted followers behind contrary to many claims. They are working on making developing Flash applications as easy as possible for people of all walks. Welcome Catalyst!
    Of course there is not enough information about AS3 capabilities and features. But, on the other hand, I don’t know any area of human kind activities that does.

  • What's wrong with this SQL?

    what's wrong with this SQL?
    Posted: Jan 16, 2007 9:35 AM Reply
    Hi, everyone:
    when I insert into table, i use the fellowing SQL:
    INSERT INTO xhealthcall_script_data
    (XHC_CALL_ENDED, XHC_SWITCH_PORT, XHC_SCRIPT_ID, XHC_FAX_SPECIFIED)
    VALUES (SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS'), HH_SWITCHPORT, HH_SCRIPT,'N'
    FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE' UNION
    SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS'), HH_SWITCHPORT, HH_SCRIPT,'N' FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE');
    I always got an error like;
    VALUES (SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS'), HH_SWITCHPORT,
    ERROR at line 3:
    ORA-00936: missing expression
    but I can't find anything wrong, who can tell me why?
    thank you so much in advance
    mpowel01
    Posts: 1,516
    Registered: 12/7/98
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 9:38 AM in response to: jerrygreat Reply
    For starters, an insert select does not have a values clause.
    HTH -- Mark D Powell --
    PP
    Posts: 41
    From: q
    Registered: 8/10/06
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 9:48 AM in response to: mpowel01 Reply
    Even I see "missing VALUES" as the only error
    Eric H
    Posts: 2,822
    Registered: 10/15/98
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 9:54 AM in response to: jerrygreat Reply
    ...and why are you doing a UNION on the exact same two queries?
    (SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS') ,HH_SWITCHPORT ,HH_SCRIPT ,'N' FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE' UNION SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS') ,HH_SWITCHPORT ,HH_SCRIPT ,'N' FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE');
    jerrygreat
    Posts: 8
    Registered: 1/3/07
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 9:55 AM in response to: mpowel01 Reply
    Hi,
    thank you for your answer, but the problem is, if I deleted "values" as you pointed out, and then execute it again, I got error like "ERROR at line 3:
    ORA-03113: end-of-file on communication channel", and I was then disconnected with server, I have to relogin SQLplus, and do everything from beganing.
    so what 's wrong caused disconnection, I can't find any triggers related. it is so wired?
    I wonder if anyone can help me about this.
    thank you very much
    jerry
    yingkuan
    Posts: 1,801
    From: San Jose, CA
    Registered: 10/8/98
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 9:59 AM in response to: jerrygreat Reply
    Dup Post
    jerrygreat
    Posts: 8
    Registered: 1/3/07
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 10:00 AM in response to: Eric H Reply
    Hi,
    acturlly what I do is debugging a previous developer's scipt for data loading, this script was called by Cron work, but it never can be successfully executed.
    I think he use union for eliminating duplications of rows, I just guess.
    thank you
    jerry
    mpowel01
    Posts: 1,516
    Registered: 12/7/98
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 10:03 AM in response to: yingkuan Reply
    Scratch the VALUES keyword then make sure that the select list matches the column list in number and type.
    1 insert into marktest
    2 (fld1, fld2, fld3, fld4, fld5)
    3* select * from marktest
    UT1 > /
    16 rows created.
    HTH -- Mark D Powell --
    Jagan
    Posts: 41
    From: Hyderabad
    Registered: 7/21/06
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 10:07 AM in response to: jerrygreat Reply
    try this - just paste the code and give me the error- i mean past the entire error as it is if error occurs
    INSERT INTO xhealthcall_script_data
    (xhc_call_ended, xhc_switch_port, xhc_script_id,
    xhc_fax_specified)
    SELECT TO_DATE (hh_end_date || ' ' || hh_end_time, 'MM/DD/YY HH24:MI:SS'),
    hh_switchport, hh_script, 'N'
    FROM tmp_healthhit_load
    WHERE hh_script != 'BROCHURE'
    UNION
    SELECT TO_DATE (hh_end_date || ' ' || hh_end_time, 'MM/DD/YY HH24:MI:SS'),
    hh_switchport, hh_script, 'N'
    FROM tmp_healthhit_load
    WHERE hh_script != 'BROCHURE';
    Regards
    Jagan
    jerrygreat
    Posts: 8
    Registered: 1/3/07
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 11:31 AM in response to: Jagan Reply
    Hi, Jagan:
    thank you very much for your answer.
    but when I execute it, I still can get error like:
    ERROR at line 1:
    ORA-03113: end-of-file on communication channel
    so wired, do you have any ideas?
    thank you very much

    And this one,
    Aother question about SQL?
    I thought I already told him to deal with
    ORA-03113: end-of-file on communication channel
    problem first.
    There's nothing wrong (syntax wise) with the query. (of course when no "value" in the insert)

  • I need help figuring out what is wrong with my Macbook Pro

    I have a mid 2012 Macbook Pro with OS X Mavericks on it and for the past few weeks it has running VERY SLOW! I have no idea what is wrong with it, i have read other discussion forums trying to figure it out on my own. So far i have had no luck in fixing the slowness. When i open applications the icon will bounce in dock forever before opening and then my computer will freeze with the little rainbow wheel circling and circling for a few minutes... and if i try to browse websites it take forever for them to load or youtube will just stop working for me. Everything i do, no matter what i click, the rainbow wheel will pop up! The only thing i can think of messing it up was a friend of mine plugging in a flash drive a few weeks ago to take some videos and imovie to put on his Macbook Pro, he has said his laptop has been running fine though... so idk if that was the problem. Anyways, could someone please help me try something? Thank you!!

    OS X Mavericks: If your Mac runs slowly?
    http://support.apple.com/kb/PH13895
    Startup in Safe Mode
    http://support.apple.com/kb/PH14204
    Repair Disk
    Steps 1 through 7
    http://support.apple.com/kb/PH5836
    Reset SMC.     http://support.apple.com/kb/HT3964
    Choose the method for:
    "Resetting SMC on portables with a battery you should not remove on your own".
    Increase disk space.
    http://support.apple.com/kb/PH13806

  • What is wrong with my IPhone? If you take a video you can't hear the audio but if I do a voice memo you can

    I don't know what's wrong with my iPhone, I can listen to music but if I try to take a video you can't hear my voice, if I take a voice memo you can hear my voice.

    try exiting the app and double clicking the home button. the multitasking apps will show up. delete all of them by holding them down and pushing the red circle (dont worry that doesnt remove them from the phone, just completely closes the app and makes your device run faster) then power off your phone by holding down thw lock button and sliding the red arrow when it comes up. wait about 5 seconds after its completely off and turn it back on. then try using the mic. hope this helps

  • What is wrong with my iphone4? and how can i turn it back on?

    About a week ago, i was using my iphone that I've had about 6 months, no problems. It was working perfectly fine and then out of nowhere it shut itself off. I plugged it in, nothing happened. I pressed the home and lock button, and held them in, and still nothing happened. The next day I decided to plug it in again, and it told me to leave it plugged in, like it was dead or something (the red battery symbol popped up, and said it was charging) and about 10 minutes later the iphone came back on. The only problem was that from here on out my home button does NOT work, at all.
    The phone was working................ until about 3 days later the same thing happened to it again, except the next day it did not come back on the same way. My mom took it to the AT&T store (living in west virginia, there aren't any Apple stores near by). She came home with it working again, but I have no clue how they got it back on.
    A few days after the second time it shut off, it happened again. We took it to AT&T again, and this time they couldn't get it back on, but they gave us some tips. We plugged it into itunes, and restored it. I was over the amount of space. I had no storage left!! So  I went through and deleted all my music, and about 500 photos (having around 1,200) . I now have about 700 photos, 20 songs, and roughly 15 apps. ONE day after I did all of this, my phone shuts off for the fourth time !!!! (It is off right now) Seeing how I have 3 GB of space left on my phone, I would think it's not a storage issue.
    I've plugged it into the wall charger, nothing! I have tried to reset it holding the home button (which still does not work) and lock button, still nothing. I have now plugged it into itunes. It says the device is found, but not identified please restore the device. So I restore it, but that doesn't help, Itunes still cant "identify" the device and it is still not on.
    I have checked for water damage, and there is not any! I just want to know what is wrong with it, and how to fix it. OR maybe if I just need to get a whole new phone, because mine is under warranty. The problem is AT&T won't give me a new one and there isn't an apple store near me! Can someone PLEASE help?

    I think you might get a new phone instead of repairing it as it takes time and you said the repairing center is far from your living place

Maybe you are looking for

  • How to get the navigation bar on top of the border?

    Hi I have captured some captivate files (in Captivate 5.5) which I need to make look similar to the existing ones. I don't have source and am not aware which version of Captivate was it built on. Now, the existing ones have the navigation panel on to

  • ASP Page to query report

    Hi there, So a long time ago we had a developer who set up an asp page that loads through some of our applications.  The asp page points to a specific report, depending on where it is called from within our application and also the parameters for tha

  • OS X lost password on used IMac

    I've purchased a used IMac from a friend.  The windows Vista side boots and runs properly.  However, when booting to OS X (via bootcamp) i'm foiled by a password screen setup by the friend's son who is uncooperative and lost.  Is there a process to r

  • Link back from CE_PAYMENT_TRANSACTIONS

    Hi all, Can anyone tell me the source table from CE_PAYMENT_TRANSACTIONS is populated from? Miranga

  • VoiceOver and Battery performance

    I'm using new iPod nano with Voiceover. It more or less works (it has its quirks, but that's for another post), but I'm really disappointed by battery performance. I charged my nano today, and after one and half hour of using it, it's at 40%. I'm not