Help needed to rewrite code so main menus move down to make way for subs

Can anybody please help me (slightly) alter some code.
I am working on a vertical menu with sub's and need to alter the AS so that when a sub menu is selected, the main menus below it move down to accommodate the new sub menu.
This is the code I am currently using is
GenerateMenu = function(container, name, x, y, depth, node_xml) {
    // variable declarations
    var curr_node;
    var curr_item;
    var curr_menu = container.createEmptyMovieClip(name, depth);
    // for all items or XML nodes (items and menus)
    // within this node_xml passed for this menu
    for (var i=0; i<node_xml.childNodes.length; i++) {
        // movieclip for each menu item
        curr_item = curr_menu.attachMovie("menuitem","item"+i+"_mc", i);
        curr_item._x = x;
        curr_item._y = y + i*curr_item._height;
        curr_item.trackAsMenu = true;
        // item properties assigned from XML
        curr_node = node_xml.childNodes[i];
        curr_item.action = curr_node.attributes.action;
        curr_item.variables = curr_node.attributes.variables;
        curr_item.name.text = curr_node.attributes.name;
        // item submenu behavior for rollover event
        if (node_xml.childNodes[i].nodeName == "menu"){
            // open a submenu
            curr_item.node_xml = curr_node;
            curr_item.onRollOver = curr_item.onDragOver = function(){
                var x = this._x + this._width -76;
                var y = this._y + 55;
                GenerateMenu(curr_menu, "submenu_mc", x, y, 10, this.node_xml);
                // show a hover color
                var col = new Color(this.background);
                col.setRGB(0xf4faff);
        }else{ // nodeName == "item"
            curr_item.arrow._visible = false;
            // close existing submenu
        curr_item.onRollOut = curr_item.onDragOut = function(){
            // restore color
            var col = new Color(this.background);
            col.setTransform({ra:100,rb:0,ga:100,gb:0,ba:100,bb:0});
        // any item, menu opening or not can have actions
        curr_item.onRelease = function(){
            Actions[this.action](this.variables);
            CloseSubmenus();
    } // end for loop
// create the main menu, this will be constantly visible
CreateMainMenu = function(x, y, depth, menu_xml){
    // generate a menu list
    GenerateMenu(this, "mainmenu_mc", x, y, depth, menu_xml.firstChild);
    // close only submenus if visible durring a mouseup
    // this main menu (mainmenu_mc) will remain
    mainmenu_mc.onMouseUp = function(){
        if (mainmenu_mc.submenu_mc && !mainmenu_mc.hitTest(_root._xmouse, _root._ymouse, true)){
            CloseSubmenus();
// closes all submenus by removing the submenu_mc
// in the main menu (if it exists)
CloseSubmenus = function(){
    mainmenu_mc.submenu_mc.removeMovieClip();
// This actions object handles methods for actions
// defined by the XML called when a menu item is pressed
Actions = Object();
Actions.gotoURL = function(urlVar){
    getURL(urlVar, "_blank");
Actions.message = function(msg){
    message_txt.text = msg;
Actions.newMenu = function(menuxml){
    menu_xml.load(menuxml);
// load XML, when done, run CreateMainMenu to interpret it
menu_xml = new XML();
menu_xml.ignoreWhite = true;
menu_xml.onLoad = function(ok){
    // create main menu after successful loading of XML
    if (ok){
        CreateMainMenu(10, 10, 0, this);
        message_txt.text = "message area";
    }else{
        message_txt.text = "error:  XML not successfully loaded";
// load first XML menu
menu_xml.load("menu1.xml");
Any help/feed back - even if its just to tell me Im asking for too much, would be incredibly appriciated.

onclipevent(load)                                           
total=_root.getbytestotal();                             
onclipevent(enterframe)
loaded=_root.getbytesloaded();
current=int(loaded/total*100);
p=""+current+"%";
if(loaded==total)
gotoandplay("Scene 2",1);
sorry for getting the code and coment mixed up.

Similar Messages

  • Help needed in this code

    Hi guys, I need help in debugging this code I made, which is a GUI minesweeper. Its extremely buggy...I particularly need help fixing the actionListener part of the code as everytime I press a button on the GUI, an exception occurs.
    help please!
    package minesweeperGUI;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class MinesweeperGUI implements ActionListener
         //Declaration of attributes
         static int length = 0;
         JMenuItem menuItemNew = new JMenuItem();
         JRadioButtonMenuItem rbEasy = new JRadioButtonMenuItem();
         JRadioButtonMenuItem rbHard = new JRadioButtonMenuItem();
         JMenuItem menuItemExit = new JMenuItem();
         JButton buttonReset = new JButton();
         JButton buttonGrid[][] = null;
         JFrame frame = new JFrame();
         int getBombsTotal = 0;
         JLabel setBombsLabel = new JLabel();
         int a = 0;
         int b = 0;     
         //No constructor created. Uses default constructor
         //Create the menu bar
         public JMenuBar newMenuBar()
              //Sets up the menubar
              JMenuBar menuBar = new JMenuBar();
              //Sets up the Game menu with choice of new, grid size, and exit
              JMenu menu = new JMenu ("Game");
              menuBar.add (menu);
              menuItemNew = new JMenuItem ("New");
              menuItemNew.addActionListener (this);
              menu.add (menuItemNew);
              menu.addSeparator();
              //Sets up sub-menu for grid size with choice of easy and hard radio buttons
              JMenu subMenu = new JMenu ("Grid Size");
              rbEasy = new JRadioButtonMenuItem ("Easy: 5x5 grid");
              rbEasy.addActionListener (this);
              subMenu.add (rbEasy);
              rbHard = new JRadioButtonMenuItem ("Hard: 10x10 grid");
              rbHard.addActionListener (this);
              subMenu.add (rbHard);
              menu.add (subMenu);
              menu.addSeparator();
              menuItemExit = new JMenuItem ("Exit");
              menuItemExit.addActionListener (this);
              menu.add (menuItemExit);
              return menuBar;
         //Setting up of Bomb Grid
         public int [][] setGrid (int length)
              int grid[][] = null;
              grid = new int[length][length];
              for (int i = 0; i < length; i++)
                   for (int j = 0; j < length; j++)
                        grid[i][j] = ((int)Math.round(Math.random() * 10))% 2;
              return grid;     
         //Setting up of the of the graphical bomb grid
         public JButton[][] setButtonGrid (int length)
              JButton buttonGrid[][] = null;
              buttonGrid = new JButton[length][length];
              for (int i = 0; i < length; i++)
                   for (int j = 0; j < length; j++)
                        buttonGrid[i][j] = new JButton();
              return buttonGrid;
         //Setting up of a way to count the total number of bombs in the bomb grid
         public int getBombsTotal (int length, int setGrid[][])
              int bombsTotal = 0;
              for (int i = 0; i < length; i++)
                   for (int j = 0; j < length; j++)
                        if (setGrid[i][j] == 1)
                             bombsTotal += 1;
              return bombsTotal;
         //Create a label for number of bombs left
         public JLabel setBombsLabel (int getBombsTotal)
              JLabel bombsLabel = new JLabel(String.valueOf (getBombsTotal) + " Bombs Left");
              return bombsLabel;
         //Setting up a way to count the number of bombs around a button
         public String setBombs (int length, int setGrid[][], int x, int y)
              int bombs[][] = new int[length][length];
              String bombsString = null;
              for (int i = 0; i < length; i++)
                   for (int j = 0; j < length; j++)
                        if (i == 0 && j == 0)
                             bombs[i][j] = setGrid[i][j+1] + setGrid[i+1][j] +
                                  setGrid[i+1][j+1];
                        else if (i ==0 && j == (length - 1))
                             bombs[i][j] = setGrid[i][j-1] + setGrid[i+1][j-1] +
                                  setGrid[i+1][j];
                        else if (i == (length - 1) && j == 0)
                             bombs[i][j] = setGrid[i-1][j] + setGrid[i-1][j+1] +
                                  setGrid[i][j+1];
                        else if (i == (length - 1) && j == (length - 1))
                             bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
                                  setGrid[i][j-1];
                        else if (i == 0 && j != 0 && j != (length - 1))
                             bombs[i][j] = setGrid[i][j-1] + setGrid[i][j+1] +
                                  setGrid[i+1][j-1] + setGrid[i+1][j] +
                                  setGrid[i+1][j+1];
                        else if (i == (length - 1) && j != 0 && j != (length - 1))
                             bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
                                  setGrid[i-1][j+1] + setGrid[i][j-1] +
                                  setGrid[i][j+1];
                        else if (i != 0 && i != (length - 1) && j == 0)
                             bombs[i][j] = setGrid[i-1][j] + setGrid[i-1][j+1] +
                                  setGrid[i][j+1] + setGrid[i+1][j] +
                                  setGrid[i+1][j+1];
                        else if (i != 0 && i != (length - 1) && j == (length - 1))
                             bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
                                  setGrid[i][j-1] + setGrid[i+1][j-1] +
                                  setGrid[i+1][j];
                        else
                             bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
                                  setGrid[i-1][j+1] + setGrid[i][j-1] +
                                  setGrid[i][j+1] + setGrid[i+1][j-1] +
                                  setGrid[i+1][j] + setGrid[i+1][j+1];
              bombsString = String.valueOf (bombs[x][y]);
              return bombsString;
         //create the panel for the bombs label and reset button
         public JPanel newTopPanel(int length)
              int setGridNew [][] = null;
              setGridNew = new int[length][length];
              int getBombsTotalNew = 0;
              JLabel setBombsLabelNew = new JLabel();
              setGridNew = setGrid (length);
              getBombsTotalNew = getBombsTotal (length, setGridNew);
              setBombsLabelNew = setBombsLabel (getBombsTotalNew);
              JPanel topPanel = new JPanel ();
              topPanel.setLayout (new BorderLayout (50,50));
              JLabel bombsLabel = new JLabel ();
              bombsLabel = setBombsLabelNew;     
              topPanel.add (bombsLabel, BorderLayout.WEST);
              buttonReset = new JButton("Reset");
              buttonReset.addActionListener (this);
              topPanel.add (buttonReset, BorderLayout.CENTER);
              return topPanel;
         //create the panel for the play grids
         public JPanel newBottomPanel(int length)
              JButton setButtonGridNew[][] = null;
              setButtonGridNew = new JButton [length][length];
              setButtonGridNew = setButtonGrid (length);
              JPanel bottomPanel = new JPanel ();
              bottomPanel.setLayout (new GridLayout (length, length));
              buttonGrid = new JButton[length][length];          
              for (a = 0; a < length; a++)
                   for (b = 0; b < length; b++)
                        buttonGrid[a] = setButtonGridNew[a][b];
                        buttonGrid[a][b].addActionListener (this);
                        bottomPanel.add (buttonGrid[a][b]);
              return bottomPanel;
         //Overiding of abstract method actionPerformed
         public void actionPerformed(ActionEvent e)
              if (e.getSource() == menuItemNew)
                   launchFrame(length);
              else if (e.getSource() == menuItemExit)
                   frame.setVisible (false);
                   System.exit(0);
              else if (e.getSource() == rbEasy)
                   length = 5;
                   launchFrame(length);
              else if (e.getSource() == rbHard)
                   length = 10;
                   launchFrame(length);     
              else if (e.getSource() == buttonReset)
                   launchFrame(length);
              else if (e.getSource() == buttonGrid[a][b])
                   int setGridNew [][] = null;
                   setGridNew = new int[length][length];               
                   JButton bombButton [][] = null;
                   bombButton = new JButton [length][length];
                   String bombString [][] = null;
                   bombString = new String[length][length];
                   setGridNew = setGrid (length);               
                   bombString[a][b] = setBombs (length, setGridNew, a, b);
                   bombButton[a][b] = new JButton (bombString[a][b]);
                   if (setGridNew[a][b] == 0)
                        buttonGrid[a][b] = bombButton[a][b];
                        getBombsTotal--;
                        JLabel setBombsLabelNew = new JLabel();
                        setBombsLabelNew = setBombsLabel (getBombsTotal);
                   else if (setGridNew[a][b] == 1 )
                        buttonGrid[a][b] = new JButton("x");
                        JOptionPane.showMessageDialog (null, "Game Over. You hit a Bomb!");
                        System.exit(0);     
         //create the content pane
         public Container newContentPane(int length)
              JPanel topPanel = new JPanel();
              JPanel bottomPanel = new JPanel();          
              topPanel = newTopPanel(length);
              bottomPanel = newBottomPanel (length);
              JPanel contentPane = new JPanel();
              contentPane.setOpaque (true);
              contentPane.setLayout (new BorderLayout(50,50));
              contentPane.add (topPanel, BorderLayout.NORTH);
              contentPane.add (bottomPanel, BorderLayout.CENTER);
              return contentPane;
         public void launchFrame (int length)
              //Makes sure we have nice window decorations
              JFrame.setDefaultLookAndFeelDecorated(true);          
              //Sets up the top-level window     
              frame = new JFrame ("Minesweeper");
              //Exits program when the closed button is clicked
              frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
              JMenuBar menuBar = new JMenuBar();
              Container contentPane = new Container();
              menuBar = newMenuBar();
              contentPane = newContentPane (length);
              //Sets up the menu bar and content pane
              frame.setJMenuBar (menuBar);
              frame.setContentPane (contentPane);
              //Displays the window
              frame.pack();
              frame.setVisible (true);
         public static void main (String args[])
              //Default length is 5
              length = 5;
              MinesweeperGUI minesweeper = new MinesweeperGUI();
              minesweeper.launchFrame(length);

    hi, thanks. that removed the exception; although now the buttons action listener won't work :(
    here is the revised code:
    To anyone out there, can you guys run this code and help me debug it?
    I'm really desperate as this is a school project of mine and the deadline is 7 hours away. I have already been working on it for 3 days, but the program is still very buggy.
    thanks!
    /* Oliver Ian C. Wee 04-80112
    * CS12 MHRU
    * Machine Problem 2
    package minesweeperGUI;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class MinesweeperGUI implements ActionListener
         //Declaration of attributes
         static int length = 0;
         JMenuItem menuItemNew = new JMenuItem();
         JRadioButtonMenuItem rbEasy = new JRadioButtonMenuItem();
         JRadioButtonMenuItem rbHard = new JRadioButtonMenuItem();
         JMenuItem menuItemExit = new JMenuItem();
         JButton buttonReset = new JButton();
         JButton buttonGrid[][] = null;
         JFrame frame = new JFrame();
         int getBombsTotal = 0;
         JLabel setBombsLabel = new JLabel();
         int a = 0;
         int b = 0;
         //No constructor created. Uses default constructor
         //Create the menu bar
         public JMenuBar newMenuBar()
              //Sets up the menubar
              JMenuBar menuBar = new JMenuBar();
              //Sets up the Game menu with choice of new, grid size, and exit
              JMenu menu = new JMenu ("Game");
              menuBar.add (menu);
              menuItemNew = new JMenuItem ("New");
              menuItemNew.addActionListener (this);
              menu.add (menuItemNew);
              menu.addSeparator();
              //Sets up sub-menu for grid size with choice of easy and hard radio buttons
              JMenu subMenu = new JMenu ("Grid Size");
              ButtonGroup bg = new ButtonGroup();
              rbEasy = new JRadioButtonMenuItem ("Easy: 5x5 grid");
              bg.add (rbEasy);
              rbEasy.addActionListener (this);
              subMenu.add (rbEasy);
              rbHard = new JRadioButtonMenuItem ("Hard: 10x10 grid");
              bg.add (rbHard);
              rbHard.addActionListener (this);
              subMenu.add (rbHard);
              menu.add (subMenu);
              menu.addSeparator();
              menuItemExit = new JMenuItem ("Exit");
              menuItemExit.addActionListener (this);
              menu.add (menuItemExit);
              return menuBar;
         //Setting up of Bomb Grid
         public int [][] setGrid (int length)
              int grid[][] = null;
              grid = new int[length][length];
              for (int i = 0; i < length; i++)
                   for (int j = 0; j < length; j++)
                        grid[i][j] = ((int)Math.round(Math.random() * 10))% 2;
              return grid;     
         //Setting up of the of the graphical bomb grid
         public JButton[][] setButtonGrid (int length)
              JButton buttonGrid[][] = null;
              buttonGrid = new JButton[length][length];
              for (int i = 0; i < length; i++)
                   for (int j = 0; j < length; j++)
                        buttonGrid[i][j] = new JButton();
              return buttonGrid;
         //Setting up of a way to count the total number of bombs in the bomb grid
         public int getBombsTotal (int length, int setGrid[][])
              int bombsTotal = 0;
              for (int i = 0; i < length; i++)
                   for (int j = 0; j < length; j++)
                        if (setGrid[i][j] == 1)
                             bombsTotal += 1;
              return bombsTotal;
         //Create a label for number of bombs left
         public JLabel setBombsLabel (int getBombsTotal)
              JLabel bombsLabel = new JLabel("  " +String.valueOf (getBombsTotal) + " Bombs Left");
              return bombsLabel;
         //Setting up a way to count the number of bombs around a button
         public String setBombs (int length, int setGrid[][], int x, int y)
              int bombs[][] = new int[length][length];
              String bombsString = null;
              for (int i = 0; i < length; i++)
                   for (int j = 0; j < length; j++)
                        if (i == 0 && j == 0)
                             bombs[i][j] = setGrid[i][j+1] + setGrid[i+1][j] +
                                  setGrid[i+1][j+1];
                        else if (i ==0 && j == (length - 1))
                             bombs[i][j] = setGrid[i][j-1] + setGrid[i+1][j-1] +
                                  setGrid[i+1][j];
                        else if (i == (length - 1) && j == 0)
                             bombs[i][j] = setGrid[i-1][j] + setGrid[i-1][j+1] +
                                  setGrid[i][j+1];
                        else if (i == (length - 1) && j == (length - 1))
                             bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
                                  setGrid[i][j-1];
                        else if (i == 0 && j != 0 && j != (length - 1))
                             bombs[i][j] = setGrid[i][j-1] + setGrid[i][j+1] +
                                  setGrid[i+1][j-1] + setGrid[i+1][j] +
                                  setGrid[i+1][j+1];
                        else if (i == (length - 1) && j != 0 && j != (length - 1))
                             bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
                                  setGrid[i-1][j+1] + setGrid[i][j-1] +
                                  setGrid[i][j+1];
                        else if (i != 0 && i != (length - 1) && j == 0)
                             bombs[i][j] = setGrid[i-1][j] + setGrid[i-1][j+1] +
                                  setGrid[i][j+1] + setGrid[i+1][j] +
                                  setGrid[i+1][j+1];
                        else if (i != 0 && i != (length - 1) && j == (length - 1))
                             bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
                                  setGrid[i][j-1] + setGrid[i+1][j-1] +
                                  setGrid[i+1][j];
                        else
                             bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
                                  setGrid[i-1][j+1] + setGrid[i][j-1] +
                                  setGrid[i][j+1] + setGrid[i+1][j-1] +
                                  setGrid[i+1][j] + setGrid[i+1][j+1];
              bombsString = String.valueOf (bombs[x][y]);
              return bombsString;
         //create the panel for the bombs label and reset button
         public JPanel newTopPanel(int length)
              int setGridNew [][] = null;
              setGridNew = new int[length][length];
              int getBombsTotalNew = 0;
              JLabel setBombsLabelNew = new JLabel();
              setGridNew = setGrid (length);
              getBombsTotalNew = getBombsTotal (length, setGridNew);
              setBombsLabelNew = setBombsLabel (getBombsTotalNew);
              JPanel topPanel = new JPanel ();
              topPanel.setLayout (new BorderLayout (20,20));
              JLabel bombsLabel = new JLabel ();
              bombsLabel = setBombsLabelNew;     
              topPanel.add (bombsLabel, BorderLayout.WEST);
              buttonReset = new JButton("Reset");
              buttonReset.addActionListener (this);
              topPanel.add (buttonReset, BorderLayout.CENTER);
              return topPanel;
         //create the panel for the play grids
         public JPanel newBottomPanel(int length)
              JButton setButtonGridNew[][] = null;
              setButtonGridNew = new JButton [length][length];
              setButtonGridNew = setButtonGrid (length);
              JPanel bottomPanel = new JPanel ();
              bottomPanel.setLayout (new GridLayout (length, length));
              buttonGrid = new JButton[length][length];          
              for (int i = 0; i < length; i++)
                   for (int j = 0; j < length; j++)
                        buttonGrid[i][j] = setButtonGridNew[i][j];
                        buttonGrid[i][j].addActionListener (this);
                        bottomPanel.add (buttonGrid[i][j]);
              return bottomPanel;
         //Overiding of abstract method actionPerformed
         public void actionPerformed(ActionEvent e)
              if (e.getSource() == menuItemNew)
                   closeFrame();
                   launchFrame(length);
              else if (e.getSource() == menuItemExit)
                   frame.setVisible (false);
                   System.exit(0);
              else if (e.getSource() == rbEasy)
                   closeFrame();
                   length = 5;
                   launchFrame(length);
              else if (e.getSource() == rbHard)
                   closeFrame();
                   length = 10;
                   launchFrame(length);     
              else if (e.getSource() == buttonReset)
                   closeFrame();
                   launchFrame(length);
              else if (e.getSource() == buttonGrid[a])
                   int setGridNew [][] = null;
                   setGridNew = new int[length][length];               
                   JButton bombButton [][] = null;
                   bombButton = new JButton [length][length];
                   String bombString [][] = null;
                   bombString = new String[length][length];
                   setGridNew = setGrid (length);               
                   for (int i = 0; i < length; i++)
                        for (int j = 0; j < length; j++)
                             bombString[i][j] = setBombs (length, setGridNew, i, j);
                             bombButton[i][j] = new JButton (bombString[i][j]);
                   if (setGridNew[a][b] == 0)
                        buttonGrid[a][b] = bombButton[a][b];
                        getBombsTotal--;
                        JLabel setBombsLabelNew = new JLabel();
                        setBombsLabelNew = setBombsLabel (" " String.valueOf (getBombsTotal) " Bombs Left");
                   else if (setGridNew[a][b] == 1 )
                        buttonGrid[a][b] = new JButton("x");
                        JOptionPane.showMessageDialog (null, "Game Over. You hit a Bomb!");
                        System.exit(0);     
         //create the content pane
         public Container newContentPane(int length)
              JPanel topPanel = new JPanel();
              JPanel bottomPanel = new JPanel();          
              topPanel = newTopPanel(length);
              bottomPanel = newBottomPanel (length);
              JPanel contentPane = new JPanel();
              contentPane.setOpaque (true);
              contentPane.setLayout (new BorderLayout(5,5));
              contentPane.add (topPanel, BorderLayout.NORTH);
              contentPane.add (bottomPanel, BorderLayout.CENTER);
              return contentPane;
         public void closeFrame ()
              frame = new JFrame ("Minesweeper");
              frame.dispose();
         public void launchFrame (int length)
              //Makes sure we have nice window decorations
              JFrame.setDefaultLookAndFeelDecorated(true);          
              //Sets up the top-level window     
              frame = new JFrame ("Minesweeper");
              //Exits program when the closed button is clicked
              frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
              JMenuBar menuBar = new JMenuBar();
              Container contentPane = new Container();
              menuBar = newMenuBar();
              contentPane = newContentPane (length);
              //Sets up the menu bar and content pane
              frame.setJMenuBar (menuBar);
              frame.setContentPane (contentPane);
              //Displays the window
              frame.pack();
              frame.setVisible (true);
         public static void main (String args[])
              //Default length is 5
              length = 5;
              MinesweeperGUI minesweeper = new MinesweeperGUI();
              minesweeper.launchFrame(length);

  • Help needed with timer codes

    i have tried to do a countdown timer but can't debug it.. can anyone help me with it or can anyone provide me with the correct coding for countdown timer..
    import java.awt.*;
    import java.Swing.*;
    import java.util.*;
    import java.awt.*;
    import java.Swing.*;
    import java.util.*;
    public class timer
         public static void main (String [] args)
              double sec = 150;
              countDown(sec);
         private Thread countDown(double seconds)
            final double time = seconds;
            Runnable runnable(){
                   public void run(){
                  try{
                    Thread.sleep(time * 1000);
                  }catch(Exception e){}
            return new Thread(runnable);
         public  void displayCountDown(){
           int seconds = 22;
           for(int i = 0; i < seconds; i++){
             Thread trd = countDown(i);
             trd.start(){
             while(trd.isAlive()){
               ; // wait
             System.out.print('\r');
             System.out.print(i);
    }

    I would suggest using javax.swing.Timer or java.util.Timer instead of implementing it yourself.

  • Help needed in rewriting the code using inner joins

    Hi all,
    I need help in rewriting this code
    DATA :  FLD LIKE ZTABLE-ZFLD,
            FLD1 LIKE ZTABLE2-ZFLD2.
    select single ZFLD from zTABLE1 into FLD
                            where MATNR  = '123' and
                                  werks = 'ABC'.
    select single ZFLD1 from zTABLE2 into FLD1
                            where  zFLD = FLD.    
    iS there way that we can write this with inner joins
    Thanks

    Hi,
    help me out
    TABLE 1 HAS
    MATNR , WERKS , FLD1.
    TABLE 2 HAS
    FLD1, FLD2.
    I KNOW MATNR AND WERKS BASED ON THAT I HAVE TO GET FLD2
    I WANT IT BE WRITTEN WITH INNEWR JOINS
    WITH FOLLOWING COD E I GET AN ERROR MESSAGE SAYING
    comma without preccing colon (after select?)
    data : FLD1 like zTABLE1-ZFLD1.
    data : FLD2 like ZTABLE2-ZFLD2.
    SELECT FZFLD1 BZFLD2
        INTO ( FLD1, FLD2)
        FROM ZTABLE1 AS F INNER JOIN ZTABLE2 AS B
               ON FZFLD1 = BFLD2
        WHERE F~MATNR = '123'
          AND F~WERKS   = 'ABC' .
    Thanks

  • Help needed in the code

    Hi all,
    I need help in acquiring this
    I have a table control,in which i have 3 columns out of which 2 are input/outfields and one is output field.
    say i have fld1 fld2 fld3
    i entera value for fld1 and fld2 then it bring value in fld3.
    but sometimes i.e certain values of fld1 the fld2 should be NA and the fld3 should open up for input.
    say fld1 = def is exception
    first i enter
    fld1 = abc and fld2 =aaa then it brings fld3 =bbb
    next i enter
    fld1 = def and hit enter then fld2 = NA and fld3 should be available for input.
    I have the following code written for this
    CONTROLS: TABLECONTROL TYPE TABLEVIEW USING SCREEN 9002.
    DATA  W_TABLECONTROL LIKE LINE OF TABLECONTROL-COLS.
    ITAB IS MY TABLE CONTROL INTERNAL TABLE I.E MY TABLE CONTROL FIELDS ARE ITAB-FLD1,ITAB-FLD2,ITAB-FLD3.
    loop at TABLECONTROL-cols into w_TABLECONTROL.
      IF w_cTABLECONTROL-screen-group4 = 'NAM'.
      loop at iTAB.
        IF ITAB-FLD1 EQ 'DEF'.
            w_TABLECONTROL-SCREEN-INPUT = '1'.
         else.
            w_TABLECONTROL-SCREEN-INPUT = '0'.
        ENDIF.
    modify TABLECONTROL-cols from w_TABLECONTROL.
       ENDLOOP.
    ENDIF.
    ENDLOOP.
    WHAT I SEE NOW WITH THIS CODE IS WHEN I ENTER THE FIRST RECORD IN
    ITAB-FLD1 AS DEF AND HIT ENTER THE FLD2 IS NA AND FLD3 IS READY FOR OUTPUT
    NOW THE SECOND ROW FLD3 IS AVAILABLE FOR INPUT WHICH I DON'T WANT BECAUSE MY FLD1 OF SECOND IS NOT YET KNOW AGAIN IFITS DEF THEN IT SHOULD BE AVAILABLE FOR INPUT OTHERWISE IT SHOULD GREY OUT.
    HELP ME IN ACHEIVING THIS.
    THANKS

    Hi,
    Have this code inside the LOOP AT ...ENDLOOP of the PBO..
    PROCESS BEFORE OUTPUT.
    LOOP AT ITAB INTO WA..
      <b>MODULE UPDATE_DATA..</b>
    ENDLOOP.
    MODULE UPDATE_DATA.
      LOOP AT SCREEN.
       IF WA-FIELD1 = 'DEF'.
    Add the group for the field3 in the attributes..    
         IF SCREEN-GROUP1 = 'G1'.
    Enable for input...
            SCREEN-INPUT = '1'.
            MODIFY SCREEN.
         ENDIF.
       ELSE.
         IF SCREEN-GROUP1 = 'G1'.
    disable for input for other values.
            SCREEN-INPUT = '0'.
            MODIFY SCREEN.
         ENDIF.
       ENDIF.
      ENDLOOP.
    ENDLOOP.
    Thanks,
    Naren

  • Help Needed with HTML code for Image Positioning

    Hi All,
    Need a little help with some code for positioning images.
    I initially used the following:
    This is fine, but the border automatically puts a black border around the photo - how do I change it to white? Is there a way to set margins too, to prevent the text butting up against the photo?
    I also used the following code with success:
    <style type="text/css"
    img
    float:right;
    border:2px solid white;
    margin: 0px 0px 15px 20px
    </style>
    This code works, however the problem with it is it is not individual to just one photo - it moved all my photos and on that page, I wanted one photo floated to left and another to the right.
    If I use this code, how can I make it photo specific, so that it only affects the placement, margins and borders of one photo?
    Any help would be great.
    Thanks

    CSS question, not iWeb question. Regardless, use inline CSS styling for the image. You can also wrap the image in its own tag and declare an id or simply declare an id for the img tag, then set the style for the id_name:
    <style type="text/css"
    img#id_name
    float:right;
    border:2px solid white;
    margin: 0px 0px 15px 20px
    </style>
    If you want to control the style of more than one image on a page but not all then use a class instead of an id.
    the border automatically puts a black border around the photo - how do I change it to white? Is there a way to set margins too, to prevent the text butting up against the photo?
    I believe you have discovered a solution for this according to your CSS code. You have set the border to white by looking at the code and adjusting it appropriately. Your margin is declared in the CSS also, adjust the pixels appropriately.
    Read up some more on CSS to educate yourself further. I suggest w3schools.com or a CSS forum instead of the iWeb forum if you have CSS questions. It's kind of like if you drive your auto to the supermarket so you decide to go to the supermarket and ask everyone in the produce section to help when you have car problems. All the supermarket does is provide a place to park your auto. If you have car problems then ask a mechanic. iWeb (and most of its users) doesn't specialize in code, it simply provides an area for you to place it. Granted you might get lucky and find a mechanic in the produce section of the supermarket, but you're more likely to find a specialist at an auto swap meet (or CSS coding forum)!

  • Help needed with Random code generator

    Hello!
    I need to find a script that allows me to show a 5 letter
    code after 20 mouse clicks.
    The mouse clicks I have sorted out, but now I would like to
    after 20 clicks show a different code from de 5 codes (ex: DRE6U;
    VG4T55, etc.) I have to display.
    Can someone help me please?
    Thanks!

    :

  • Help needed on java code

    Hi all,
    In the below code, if condition is failing. what might be the reason.......??
    String mAmtBaseStr = "-00000000000200.00";
              if (mAmtBaseStr.substring(0).equals("-"))
                   //strip "-" from first char
                   int len1 = mAmtBaseStr.length();
                   mAmtBaseStr = mAmtBaseStr.substring((1 - 0),len1);
                   //put the stripped "-" at last
                   mAmtBaseStr = mAmtBaseStr + "-";
    I tried other options like,
              if (mAmtBaseStr.substring(0,1).equals("-"))  etc etc......

    Hi,
            This code fails because of this reason
    _problem1 _
    String mAmtBaseStr = "-00000000000200.00";
    mAmtBaseStr.substring(0)-------> -00000000000200.00 [as substring(0) returns entire string starting from index zero.]
    when you are writing
    if (mAmtBaseStr.substring(0).equals("-"))
         You are tryring to check if the value mAmtBaseStr.substring(0) [ "-00000000000200.00"] is equal to string "-" or not.
          As you can see the strings are not equal the if condition never returns you true value.
    _Problem2_
    you are nowhere checking whether the inbound string is null or empty. In case the string comes as null or empty java will throw an exception and your mapping will fail. So if input string does not begin with an hyphen you need to pass it as it is
    Thus I would modify your code a little bit to make it work
    public static String removeHyphen(String mAmtBaseStr)
              if (mAmtBaseStr!=null && mAmtBaseStr!="" && mAmtBaseStr.substring(0,1).equals("-"))
                   //strip "-" from first char
                   int len1 = mAmtBaseStr.length();
                   mAmtBaseStr = mAmtBaseStr.substring((1 - 0),len1);
                   //put the stripped "-" at last
                   mAmtBaseStr = mAmtBaseStr + "-";
              return mAmtBaseStr;
    This code works and produces required output
    input: -00000000000200.00
    output: 00000000000200.00-
    Regards
    Anupam

  • Help needed with simple code

    Hi,
    Im doing a project for my module at uni. Not being a programmer I find it very hard to design application as Im required to. Anyway I have to design booking application for bikeshop.
    User selects bike from 3 types: MTB,Kids and racing. each bike has its price so cost of booking must be calculated.There are extra options like helmet which may rented as well. Some customer info must be collected (name,address etc).
    Bookings has to be written into file. Report of past booking must be available-simple printouts.
    No databases as use of arrays is required.
    Im stuck and trying to figure it out how to read from array which contains bike types and prices and extra features. Then combine several bookings for on customes on a form/interface.
    Any ideas how to start it? I mean at least on design level.
    Thanks in advance for any help

    Hi
    I managed to produced some code to extend my app but when I run it I get:
    Exception in thread "main" java.lang.NullPointerException
         at ReservationSystem.main(ReservationSystem.java:22)
    Im really stuck
    Will somebody give me any idea?
    Below is the code...
    Thanks
    whale
    mport java.util.ArrayList;
    import javax.swing.JOptionPane;
    public class ReservationSystem {
         static ArrayList<Booking> Bookings;
         public static void main(String[] args) {
              int BikeType = 0;
              do {
                   BikeType = Integer.parseInt(JOptionPane.showInputDialog("0 - Mountain bike, 1 - Racing Bike, 2 - Childrens Bike, 3 - Finish?"));
                   String Surname = JOptionPane.showInputDialog("Surname?");
                   String Date = JOptionPane.showInputDialog("Date?");
                   int Number_of_days = Integer.parseInt(JOptionPane.showInputDialog("Number of days?"));
                   switch (BikeType) {
                   case 0:
                        String Sex = JOptionPane.showInputDialog("Sex (M/F)?");
                        String Frame_size = JOptionPane.showInputDialog("Frame size (S/M/L)?");
                        boolean Helmet = JOptionPane.showConfirmDialog(null, "Is a helmet required?", "Helmet", JOptionPane.YES_NO_OPTION) == 0;
                        Bicycle Bike = new MountainBike(Sex, Frame_size, Helmet);
                        Bookings.add(new Booking(Surname, Date, Number_of_days, Bike));
                   case 1:
                   case 2:
                   default:
              } while (BikeType != 3);
              int Length = Bookings.size();
              int i;
              for (i = 0; i < Length; i++) {
               Bookings.get(i).print_booking();
         }Booking class
    public class Booking {
      //Date start_date;
      int Number_of_days;
      Bicycle Bike;
      String Surname;
      String Date;
      Booking(String Surname, String Date, int Number_of_days, Bicycle Bike) {
           this.Surname = Surname;
           this.Number_of_days = Number_of_days;
           this.Bike = Bike;
           this.Date = Date;
      public void print_booking() {
           System.out.print(this.Surname + ": " + this.Date + "/" + " for " + this.Number_of_days);
           this.Bike.print_bike();
      }}class Bicycle
    public class Bicycle {
      int Price;
      boolean Helmet;
         public void print_bike() {
    class MountainBike extends Bicycle {
         String Frame_size;
         String Sex;
         public MountainBike(String Sex, String Frame_size, boolean Helmet) {
              this.Sex = Sex;
              this.Frame_size = Frame_size;
              this.Helmet = Helmet;
              this.Price = 20;
              if (Helmet) {
                   this.Price += 5;
         public void print_bike() {
              System.out.println("Mountain bike (" + this.Sex + ", " + this.Frame_size + ") "
                        + (this.Helmet ? " with helmet" : "") + " price " + this.Price);
    class RacingBike extends Bicycle {
         boolean Panniers;
         String Frame_size;
         String Sex;
         public RacingBike(String Sex, String Frame_size, boolean Panniers) {
              this.Sex = Sex;
              this.Frame_size = Frame_size;
              this.Panniers = Panniers;
              this.Price = 25;
              if (Panniers) {
                   this.Price += 10;
                   this.Helmet = true;
         public void print_bike() {
              System.out.println("Racing bike (" + this.Sex + ", " + this.Frame_size + ") "
                        + (this.Panniers ? " with panniers" : "") + " price " + this.Price);
    class ChildrensBike extends Bicycle {
         int Age;
         public ChildrensBike(int Age) {
              this.Age = Age;
              this.Helmet = true;
              this.Price = 15;
         public void print_bike() {
              System.out.println("Mountain bike (" + this.Age + ") "
                        + (this.Helmet ? " with helmet" : "") + " price " + this.Price);
    }

  • Help needed on a code!!!!

    Error: PLS-00103: Encountered the symbol "L_RATEDATE" when expecting one of the following:
    language
    Line: 33
    I am getting the above error when i try to compile the below code
    FUNCTION fer_fn_get_Rate(
              pBranch     IN          BRANCH.BRANCH_CODE%TYPE,
              pCcy1          IN           CrCY_DEFN.CrCY_CODE%TYPE,
              pCcy2          IN           CrCY_DEFN.CrCY_CODE%TYPE,
              pRateType     IN           RATE_TYPE.CrCY_RATE_TYPE%TYPE,
              vIndicator     IN      CHAR,
              vDate          IN          DATE,
              vBranchDate     IN          DATE ,
              vRate          IN OUT     RATES.MD_RATE%TYPE,
              vRateFlag     IN OUT     NUMBER,
              vErrorCode     IN OUT      MSGS.ERR_CODE%TYPE )
    return BOOLEAN as
    l_rateDate      DATE;---Error point
    l_rateType      RATE_TYPE.CrCY_RATE_TYPE%TYPE;
    l_indicator CHAR;

    > well it is too lengthier....10000 lines...
    I trust that this is a package - and a 10,000 line procedure or function. If not.. ouch. Modularisation is not something "nice". It is mandatory.
    Assuming it is a package and you're getting that error - there is seemingly nothing wrong with that function header and variables. So why would the PL/SQL parser raise an error there?
    The problem could be much earlier - and that point could simply where the PL/SQL parser realised that there is an error. For example, you may have missed an END command for a procedure/function further up in the package. Or have a BEGIN too many. There could be a bracket too many or too few. Etc.
    Many of these type of mistakes in the code results in the parser attempting to legally parse the code that follows - and only way down in that, realise that something is amiss. And then it raises an error at that point - the point where it discovered the error. Which is not the point where the error was caused.
    There are a couple of ways to try and determine where this bug in the code is. One I prefer is to use comments to comment out large blocks of data (around the error discovery point reported) - and then compile and see where the error is discovered now.

  • Help needed reg this code

    & Include MZFBPS_TRREQTOP                                   Module poo
    PROGRAM  SAPMZFBPS_TRREQ .
    tables : ZFBPS_TRPTR_REQ,
             ZFBPS_CONT_HD,
             ZFBPS_CONT_DT.
    data:     OK_CODE like sy-ucomm,
              save_ok(4).
    data : it_gate like standard table of ZFBPS_TRPTR_REQ,
           wa_gate like line of it_gate.
    TYPES: BEGIN OF values,
             TRANSPORTER_CODE TYPE ZFBPS_CONT_HD-TRANSPORTER_CODE,
             TRUCK_CODE TYPE ZFBPS_CONT_DT-TRUCK_CODE,
             DESTINATION TYPE ZFBPS_CONT_DT-DESTINATION,
           END OF values.
    DATA: TRANS(5) TYPE c,
          TRUCK(15) TYPE c.
    DATA: progname TYPE sy-repid,
          dynnum   TYPE sy-dynnr,
          dynpro_values TYPE TABLE OF dynpread,
          field_value LIKE LINE OF dynpro_values,
          values_tab TYPE TABLE OF values.
    *&      Module  INIT  OUTPUT
          text
    MODULE INIT OUTPUT.
    progname = sy-repid.
      dynnum   = sy-dynnr.
      CLEAR: field_value, dynpro_values.
      field_value-fieldname = 'TRANS'.
      APPEND field_value TO dynpro_values.
    ENDMODULE.                 " INIT  OUTPUT
    *&      Module  VALUE_TRANS  INPUT
          text
    MODULE VALUE_TRANS INPUT.
    CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'
           EXPORTING
                tabname     = 'ZFBPS_CONT_HD'
                fieldname   = 'TRANSPORTER_CODE'
                dynpprog    = progname
                dynpnr      = dynnum
                dynprofield = 'TRANS'.
    ENDMODULE.                 " VALUE_TRANS  INPUT
    *&      Module  VALUE_TRUCK  INPUT
          text
    MODULE VALUE_TRUCK INPUT.
    CALL FUNCTION 'DYNP_VALUES_READ'
           EXPORTING
                dyname             = progname
                dynumb             = dynnum
                translate_to_upper = 'X'
           TABLES
                dynpfields         = dynpro_values.
      READ TABLE dynpro_values INDEX 1 INTO field_value.
      SELECT ATRANSPORTER_CODE BTRUCK_CODE b~DESTINATION
    FROM ( ZFBPS_CONT_DT AS B INNER JOIN ZFBPS_CONT_HD AS A
           ON ACONTRACT_NUM EQ BCONTRACT_NUM )
    INTO CORRESPONDING FIELDS OF TABLE values_tab
    WHERE A~TRANSPORTER_CODE = field_value-fieldvalue.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
           EXPORTING
                retfield    = 'TRUCK_CODE'
                dynpprog    = progname
                dynpnr      = dynnum
                dynprofield = 'TRUCK'
                value_org   = 'S'
           TABLES
                value_tab   = values_tab.
    ENDMODULE.                 " VALUE_TRUCK  INPUT
    In values_tab I have three fields and I wish to return all the three fields,but at present I am able to return only one field (TRUCK). How to return other fields.
    Please suggest a solution.
    Regards,
    Deepak.

    Do not pass the dynprofield parameter and check.
    Regards,
    Ravi

  • Help needed about DefaultTableModel code

    Hi,
    Can anybody tell me what is wrong about the construction of my JTable. I create the instance of the below class and add to my JTable:
    MyTableModel myModel = new MyTableModel();
    JTable costTable = new JTable(myModel);
    I can see printouts "MTM_1,2,3,4" then it gives me an exception
    Exception caught in Scenegraph: 16 >= 16
    The vector IFC_Tree.totalVector has members like:
    IFC_Tree.totalVector[0]: [IFCBeam, 4.962499618530273, m3, 0.0, 0.0]
    IFC_Tree.totalVector[1]: [IFCColumn, 13.84760570526123, m3, 0.0, 0.0]
    IFC_Tree.totalVector[2]: [IFCFloor, 113.82814025878906, m3, 0.0, 0.0]
    IFC_Tree.totalVector[3]: [IFCWall, 229.7195587158203, m3, 0.0, 0.0]
    IFC_Tree.totalVector[4]: [IFCRoofSlab, 215.8400421142578, m2, 0.0, 0.0]
    IFC_Tree.totalVector[5]: [IFCWindow_2.375*2.45, 8.0, number, 0.0, 0.0]
    IFC_Tree.totalVector[6]: [IFCWindow_0.6*0.6, 20.0, number, 0.0, 0.0]
    IFC_Tree.totalVector[7]: [IFCWindow_3.85*2.45, 3.0, number, 0.0, 0.0]
    IFC_Tree.totalVector[8]: [IFCWindow_2.0*2.1, 2.0, number, 0.0, 0.0]
    IFC_Tree.totalVector[9]: [IFCDoor_0.9*2.1, 17.0, number, 0.0, 0.0]
    IFC_Tree.totalVector[10]: [IFCDoor_1.8*2.45, 2.0, number, 0.0, 0.0]
    IFC_Tree.totalVector[11]: [IFCDoor_0.8*2.1, 28.0, number, 0.0, 0.0]
    IFC_Tree.totalVector[12]: [IFCDoor_0.9*2.45, 11.0, number, 0.0, 0.0]
    IFC_Tree.totalVector[13]: [IFCDoor_2.0*2.1, 2.0, number, 0.0, 0.0]
    IFC_Tree.totalVector[14]: [IFCDoor_1.0*2.1, 4.0, number, 0.0, 0.0]
    IFC_Tree.totalVector[15]: [null, null, null, TOTAL COST, 0.0]
    import javax.swing.JTable;
    import javax.swing.table.AbstractTableModel;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.JScrollPane;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    import javax.swing.JOptionPane;
    import java.awt.*;
    import java.awt.event.*;
    import java.lang.*;
    import javax.swing.DefaultCellEditor;
    import java.util.Vector;
    //public class MyTableModel extends AbstractTableModel
    public class MyTableModel extends DefaultTableModel
    private boolean DEBUG = true;
    static double totalCost = 0.0;
    static Vector data = new Vector();
    static Vector columnNames = new Vector();
    static Vector tmp;
    public MyTableModel()
    System.out.println("MTM_1");
    addColumn("IFCOBJECTS OR PROCESSES");
    addColumn("QUANTITY");
    addColumn("UNITS");
    addColumn("UNIT COST (�)");
    addColumn("TOTAL COST (�)");
    System.out.println("MTM_2");
    for(int i=0; i < IFC_Tree.totalVector.size(); i++)
    System.out.println("MTM_3");
    tmp = (Vector)(IFC_Tree.totalVector.elementAt(i));
    System.out.println("MTM_4");
    addRow(tmp);
    System.out.println("MTM_5");
    System.out.println("MTM_6");
    public int getColumnCount()
    return columnNames.size();
    public int getRowCount()
    public String getColumnName(int col)
    public Object getValueAt(int row, int col)
    public boolean isCellEditable(int row, int col)
    public void setValueAt(Object value, int row, int col)
    }

    I don't understand why you override the methods getRowCount() ... and why there are the static member variables columnNames .... (all this is done by the DefaultTableModel). Your table model initialization in the constructor should suffice.
    Pierre

  • Main content moves down in IE

    Ok, here’s a quick question. This layout works in all
    the browsers except IE 7 (I haven’t tried 6 or 5.5). In IE 7
    it displays the main content below the sidebar floated to the
    right. I tried ‘clear’ on both the sidebar and main
    content. The conditional comments seem to work but, don’t
    seem to quite fix the problem and I’m not sure if
    that’s it or if they’re set up correctly.
    I know I’m missing something probably easy. Any help
    would be appreciated.
    Here’s the url
    http://www.garza-design.com/testsite/santa_b/index.html.
    Thanks...

    Opppss. Therewas a period at the end. Here you go.
    http://www.garza-design.com/testsite/santa_b/index.html
    Thanks...

  • I have tried another exercise, but again I will need help, here's the code

    hi,
    I have another problem. here's the question pluss the code.
    public interface Patient{
    public void doVisit(float hour);
    public boolean hospitalize();
    1. I will need to write a class name OrdinaryPatient which extends Patient.
    the class will include value int that his name age and another value that will be boolean
    of disease.
    I have to do two constructors. one that don't get values and give them default and the other one
    that does get values.
    another method name docVisit which get a visit to the doctor time visit and will print a message.
    the method hospitalize will hospitalize the patient (and if he will have disease he will get true).
    and for age I have to write methods of get and set.
    2. I will need to write a class of Hipochondriac that extends from OrdinaryPatient.
    I have to do two constructors. one that don't get values and make default and the other one that do get values.
    I will need to ade int by the name of numberOfHospitalize.
    I will need to move the method hospitalize that it will be possible to hospitalize the hypochondriac
    on with the value numberOfHospitalize that his small from 5 and if he will hospitalize he will return
    the value true.
    3. write class PatientClass which will be the method main.
    do 10 objects from OrdinaryPatient, 5 that don't get values and 5 will get randomaly age and
    chronic disease with true.
    do 10 objects from Hipochonidraic, 9 that don't get values and one get all of them.
    save all objects in value from Patinet.
    print for each of them their age.
    print for the OrdinaryPatient alone the method of Hospitalize.
    ok, here's what I did.
    1. OrdinaryPatient
    pbulic class OrdinaryPatient implements Patient{
    private int age;
    private boolean disease;
    public OrdinaryPatient(){
    this.disease=false;
    this.age=0;
    public OrdinaryPatient(int age,boolean ddisase){
    this.disease=disease;
    this.age=age;
    public int getAge(){
    return age;
    public void setDisease(boolean disease){
    this.disease=disease;
    public void setAge(int age){
    this.age=age;
    public void docVisit(){
    System.out.println("Patient's visit is one hour");
    public boolean hospitalize(){
    return false;
    2. public class Hipochondriac extends OrdinaryPatient{
    private = numberOfHospitalize;
    public Hipochondriac();
    super();
    numberOfHospitalize=0;
    public Hipochondriac(int age, boolean diseased, int numberOfHospitalize){
    super(age.diseased);
    setnumberOfHospitalize(numberofHospitalize);
    from here I don't know how to continue.
    3. public class PatientClass{
    public static void main(String args[]){
    patient patinets= new patient[20];
    for (int i=0; i<5; i++){
    patients= new OrdinaryPatient();
    from i'm stuck!!!
    if you can help me to improve it I will appriciate it...
    Einat

    here my result.
    1. public interface Patient{
         public void docVisit(float hour_;
         public boolean hospitalize();
    public class OrdinaryPatient extends Patient
         private int age;
         private boolean disease;
    //constructors
         public OrdinaryPatient(){
              age=20;
              disease=true;
         public OrdinaryPatient(int age, boolean disease) {
              setAge(age);
              this.disease=disease;
    //methods
         public int getAge() {
              return age;
         public void setAge(boolean disease) {
              if(age>0 && age<120)
                   this.age=age;
         //overriding methods.
         public void docVisit(float hour) {
              System.out.println("your visit turn is at "+hour");
         public boolean hospitalize(){
              System.out.println("go to hospital");
              if(disease)
                   return true;
              else
                   return false;
    2. public class Hipochondriac extends OrdinaryPatient{
         private int numberOfHospitalize;
    //constructors
         public Hipochondriac(){
         public Hipochondriac(int age, boolean disease, int numberOfHospipitalize){
              setAge(age);
              this.disease=disease;
              this.numberOfHospitalize=numberOfHospitalize
         //methods
         public int getNumberOfHospitalize(){
              return numberOfHospitalize;
         public void setNumberOfHospitalize(int numberOfHostpitalize){
              if(numberOfHospitalize>0)
                   this.numberOfHospitalize=numberOfHospitalize;
         public boolean hospitalize(){
              if(numberOfHospitalize<5)
                   System.out.println("go to hospital");
                   numberOfHospitalize++;
                   return true;
              else
                   return false;
    3. public class PatientClass
         //constructors
         private PatientClass(String[] args){
              //private methods helps to build the object.
              intialArr(args);
              printAge();
              gotHospital();
    //methods.
    private void intialArr(String[] args){
         int i;//array index
         for(i=0;i<arr.lents/2;i+=2)
              arr=new OrdinaryPatient();
              arr[i+1]=new OridnaryPatient((int)(Math.random()*121),true);
         for(;i<=arr.length-2;i++)
              arr[i]=new Hipochondriac();
         arr[i]=new Hipochondriac(Interget.parseINt(args[0]),
         private void printAge(){
              for(int i=0;i<arr.length;i++)
                   System.out.println(((OrdinaryPatient)arr[i]).getAge());
         private void gotoHospital(){
              for(int i=0;i<arr.length;i++)
    //checking for ordinarypatient objects only
                   if(!(arr[i] instanceof Hipochondriac))
                        //dont need casting
                        arr[i].hospitalize()[
         //main method
         public static void main(String[] args)
              //setting the commandLine array from the main to PatientClass object
              PatientClass pc=new PatientClass(args);
    let me know if it's seems logic to you.
    thank you, Einat     

  • Help a Newbie - Need to Embed swfs into main swf

    I have made a MAIN SWF in which if you click one button, it
    loads one SWF, if you click another button, it loads another SWF.
    The file works perfectly when I test the MAIN SWF...until I
    relocate that MAIN SWF to another file, then it doesn't load the
    internal SWFS. How do I publish the MAIN SWF with the other two
    SWFS embedded? So that my client only has to upload one single SWF
    file and not host the internal ones somewhere?
    Hope this makes sense...Flash is completely foreign to me, so
    be gentle. Thanks!

    Treat Flash as any other content and place it within its own
    containing div. Position the div in the normal flow of the document
    allowing the div to 'stack' with the other divs above and below it.
    If you want to place the Flash such that it 'covers' existing
    content you can use CSS positioning techniques. Options include
    absolute positioning the containing div with the Flash swf within
    it (this removes the div from the normal flow of the document) and
    placing it over the existing content. Us position: absolute; and
    top and left, with px values to place the div where you need it.
    You can find tutorials on absolute positioning in the developer
    center or www.communitymx.com
    You can use the float property and negative margins to pull
    containing divs (or other elements) around the document, too.
    Experimenting with floats can be fun but you need to read up on
    their specific behavior as you can end up pulling your hair out.
    Again, there are plenty of CSS tutorials on positioning and a
    Google search should throw-up some options.
    Outside of CSS you can use DOM Scripting and JavaScript to
    also position and hide various content depending on your
    requirements. If you get stuck come back on this forum and ask for
    more help but provide specific code to help us.

Maybe you are looking for

  • Trouble using Creative's Live! Cam Video IM Pro

    I have just buy a new webcam and installer all that should be and upgrade.But in cam detector and Msn is my cam not with me when i move around , the pic be blurred and laggy.what can be wrong.what should i do to fix the problem?I have 2,40 GHz and 76

  • "Save As" not responding when downloading a PDF

    I routinely download PDFs which has never been a problem.  As of today I am receiving a message stating "Save As" is not responding.  I have attempted to repair the program but it is still not responding. I am running Windows 8.1

  • HT4528 problem with imessge network after updating to i07

    Having trouble with iphone 4s after updating to iO7.  imessage won't activate, it says could not sign in.  Please check your network connections. This has been happening since last night.

  • Approve and Notify in Integrated Planning

    I am wanting to implement an Approve and Notify functionality in my planning application in Integrated Planning. i.e. When all assistants have submitted their yearly goals, I want to be able to notify the regional manager that they can begin reviewin

  • Pdf report

    Hi, I am new to the oracle reports so i need your kind advise, suggestions for the follwoing: I have to create 6 pdf reports, each one will have 4 sub sections, user will click the print button on the form and then it will prints these 6 reports inlu