Anyone spot the problem with this program???

Everytime I compile part of my program it keeps on saying....
"missing return statement
^
1 error"
can anyone spot it on my program???
//GAME
public class Game2 extends MyPrint
     GameInterface gameInt;
     String s = "?123456789";
     Player player1;
     Player player2;
     public Game2() // Constructor
     public int makeMove()
          gameInt = new GameInterface ();
          player1 = new Player ();
          player2 = new Player ();
          myPrintln("Enter name of player");
          String FP = c.input.readString();
          myPrintln(FP, SYSTEM);
          myPrintln("Enter name of other player");
          String SP = c.input.readString();
          myPrintln(SP, SYSTEM);
          gameInt.pictureBoard(s);
          myPrintln("");
          //boolean whoWon=false;
          int loop = 0;
          while(loop<=6)
               player1.setName(FP);
               myPrintln(player1.getName() + " (X) to play");
               char name1 = c.input.readChar();
               name1 = c.input.readChar();
               boolean playTurn = true;
               gameInt.play(name1, true);
               gameInt.pictureBoard(gameInt.display());
               myPrintln("");
               player2.setName(SP);
               myPrintln(player2.getName() + " (O) to play");
               char name2 = c.input.readChar();
               name2 = c.input.readChar();
               playTurn = false;
               gameInt.play(name2, false);
               gameInt.pictureBoard(gameInt.display());
               myPrintln("");
               loop++;
cheers
Dave

Change public int makeMove() into: public void makeMove()
and the compiler will keep quiet (or finds more things to complain about)

Similar Messages

  • Can anyone spot the problem with this coding??

    can anyone spot this problem with my program. it keeps saying
    "missing return statement } " with a little arrow beneath the bracket.
    many thanks
    public class Game extends GameInterface
         GameInterface gameInt = new GameInterface();
         String boardString;
         // final static char NOUGHT='O', CROSS='X';
         private int square = 0;
         Player player1 = new Player();
         Player player2 = new Player();
         String firstPlayer, secondPlayer;
         public Game() // Constructor
              boardString = "0123456789";
    public boolean initialise(boolean first)
                   gameInt.setPlayerNames(player1,player2);
              MyPrint.myPrintln("Player one name is " + player1.getName());
              MyPrint.myPrintln("Player two name is " + player2.getName());
              String P1 = player1.getName();
              String P2 = player2.getName();
    }

    It means you declare your method to return something, but you don't actually return anything.

  • Vector, what is the problem with this code?

    Vector, what is the problem with this code?
    63  private java.util.Vector data=new Vector();
    64  Vector aaaaa=new Vector();
    65   data.addElement(aaaaa);
    74  aaaaa.addElement(new String("Mary"));on compiling this code, the error is
    TableDemo.java:65: <identifier> expected
                    data.addElement(aaaaa);
                                   ^
    TableDemo.java:74: <identifier> expected
                    aaaaa.addElement(new String("Mary"));
                                    ^
    TableDemo.java:65: package data does not exist
                    data.addElement(aaaaa);
                        ^
    TableDemo.java:74: package aaaaa does not exist
                    aaaaa.addElement(new String("Mary"));Friends i really got fed up with this code for more than half an hour.could anybody spot the problem?

    I can see many:
    1. i assume your code snip is inside a method. a local variable can not be declare private.
    2. if you didn't import java.util.* on top then you need to prefix package on All occurance of Vector.
    3. String in java are constant and has literal syntax. "Mary" is sufficient in most of the time, unless you purposly want to call new String("Mary") on purpose. Read java.lang.String javadoc.
    Here is a sample that would compile...:
    public class QuickMain {
         public static void main(String[] args) {
              java.util.Vector data=new java.util.Vector();
              java.util.Vector aaaaa=new java.util.Vector();
              data.addElement(aaaaa);
              aaaaa.addElement(new String("Mary"));
    }

  • 2 hrs & 1.8GB lost as illust CC download crashes. Anyone else have problems with this?

    2 hrs & 1.8GB lost as illust CC download crashes. Anyone else have problems with this? (It was completely downloaded & just about to install and then it dropped out)

    Bootup holding CMD+r, or the Option/alt key to boot from the Restore partition & use Disk Utility from there to Repair the Disk, then Repair Permissions.
    If that doesn't work...
    To find out if it's system wide or user specific, try this...
    Open System Preferences>Users & Groups, unlock the lock, click on the little plus icon, make a new admin account, log out & into the new account.
    Does it work in the new account?

  • Does ANYONE know whats wrong with this program?!?!

    Hey(again),
    Does anyone know whats wrong with this program?:
    public class FloatingNumbersTest
    public static void main(String args[])
    float float1 =50.0f;
    float closeFloat=0.001f
    float farfloat=100.0f
    if (float1<=closeFloat)
    System.out.print("Float1 pretty close to zero");
    if (float1>=closeFloat)
    System.out.print("Float1 is near 0");
    if (float1>=farfloat)
    System.out.print("Float1 is not even close to zero!"0
    }There has seemed to be 5 errors!

    public class FloatingNumbersTest
    public static void main(String args[])
    float float1 =50.0f;
    float closeFloat=0.001f
    float farfloat=100.0f
    if (float1<=closeFloat)
    HERE        System.out.print("Float1 pretty close to zero");
    if (float1>=closeFloat)
    System.out.print("Float1 is near 0");
    if (float1>=farfloat)
    System.out.print("Float1 is not even close to zero!"0
    }you're missing the opening { for the first if.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Please tell me what is the problem with this code

    Hai,
    Iam new to Swings. can any one tell what is the problem with this code. I cant see those controls on the frame. please give me the suggestions.
    I got the frame ,but the controls are not.
    this is the code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class ex2 extends JFrame
    JButton b1;
    JLabel l1,l2;
    JPanel p1,p2;
    JTextField tf1;
    JPasswordField tf2;
    public ex2()
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setTitle("Another example");
    setSize(500,500);
    setVisible(true);
    b1=new JButton(" ok ");
    p1=new JPanel();
    p1.setLayout(new GridLayout(2,2));
    p2=new JPanel();
    p2.setLayout(new BorderLayout());
    l1=new JLabel("Name :");
    l2=new JLabel("Password:");
    tf1=new JTextField(15);
    tf2=new JPasswordField(15);
    Container con=getContentPane();
    con.add(p1);
    con.add(p2);
    public static void createAndShowGUI()
    ex2.setDefaultLookAndFeelDecorated(true);
    public static void main(String ar[])
    createAndShowGUI();
    new ex2();
    }

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class ex2 extends JFrame
        JButton b1;
        JLabel l1,l2;
        JPanel p1,p2;
        JTextField tf1;
        JPasswordField tf2;
        public ex2()
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            setTitle("Another example");
            b1=new JButton(" ok ");
            p1=new JPanel();
            p1.add(b1);
            p2=new JPanel();
            p2.setLayout(new GridLayout(2,2));
            l1=new JLabel("Name :");
            l2=new JLabel("Password:");
            tf1=new JTextField(15);
            tf2=new JPasswordField(15);
            p2.add(l1);
            p2.add(tf1);
            p2.add(l2);
            p2.add(tf2);
            Container con=getContentPane();
            con.add(p1, BorderLayout.NORTH);
            con.add(p2, BorderLayout.CENTER);
            pack();
            setVisible(true);
        public static void createAndShowGUI()
            ex2.setDefaultLookAndFeelDecorated(true);
        public static void main(String ar[])
            createAndShowGUI();
            new ex2();
    }

  • Encore CS4 (version 4.0.0.258) will not finish burning to blu-ray disc when using a menu template.  DVD burning works fine.  Anyone know the problem with blu-ray?  HELP!

    Encore CS4 (version 4.0.0.258) will not finish burning to blu-ray disc when using a menu template.   DVD burning works fine with menu template.  Anyone know the problem with blu-ray?  HELP!

    For CS4 you must update the Roxio component, especially with Win8
    http://forums.adobe.com/thread/1309029 http://docs.roxio.com/patches/pxengine4_18_16a.zip
    http://corel.force.com/roxio/articles/en_US/Master_Article/000012592-PX-Engine-Description -and-Download

  • I was playing candy crush and I had too much problem with my bill your charge too much I want to know what is the problem with this game cost

    HELLO
    I was playing candy crush and I had too much problem with my bill your charge too much I want to know what is the problem with this game cost

    Take it up with iTunes Support - we are not Apple here, we are just users like you:
    http://www.apple.com/support/itunes/ww/
    Cheers,
    GB

  • What is the problem with this Stored Procedure

    Hi ,
    What is the problem with this Stored Procedure ?Why is it giving errors ??
    CREATE or replace  PROCEDURE getEmpName
    *(EMP_FIRST OUT VARCHAR2(255))*
    BEGIN
    SELECT ename INTO EMP_FIRST
    FROM Emp
    WHERE EMPNO = 7369;
    END ;
    */*

    You don't specify precision in procedure arguments.
    (EMP_FIRST OUT VARCHAR2(255))should be
    (EMP_FIRST OUT VARCHAR2)Since you asked what's wrong with it, I could add that it needs formatting and the inconsistent use of upper and lower case is not helping readability.

  • Problem with this program

    I see this board is very young. Well I'm a high school freshman in a java programming class and i have a little problem with my homework.
    My source code is:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.text.DecimalFormat;
    public class DogsHumanAge extends JApplet
    implements ActionListener
    JTextField inputHumanyears, displayDogyears;
    public void init()
    JLabel labelHumanyears = new JLabel("Enter the dog's age in human years:",
    SwingConstants.RIGHT);
    inputHumanyears = new JTextField(5);
    JLabel labelDogyears = new JLabel("Dogyears = ", SwingConstants.RIGHT);
    displayDogyears = new JTextField(5);
    displayDogyears.setEditable(false);
    JButton go = new JButton("Compute age");
    go.addActionListener(this);
    Container c = getContentPane();
    c.setBackground(Color.white);
    JPanel p = new JPanel();
    p.setLayout(new GridLayout(3, 2, 5, 5));
    p.add(labelHumanyears);
    p.add(inputHumanyears);
    p.add(labelDogyears);
    p.add(displayDogyears);
    c.add(p, BorderLayout.CENTER);
    c.add(go, BorderLayout.SOUTH);
    public void actionPerformed(ActionEvent e)
    int Humanyears = Integer.parseInt(inputHumanyears.getText());
    double Dogyears = calculateDogyears(Humanyears);
    DecimalFormat df = new DecimalFormat("00.0");
    displayDogyears.setText(df.format(Dogyears));
    private double calculateDogyears(int Humanyears, int Dogyears)
    return 13 + (int)(16.0 / 3.0 * (Dogyears - 1));
    The error message i get is:
    DogsHumanAge.java:42: calculateDogyears(int, int) cannot be applied to (int)
    double Dogyears = calulateDogyears(Humanyears);
    The intent of this program is to calculate the number of dog years from the given human years that is inputted into the input box.

    Ok I got the solution. A friend helped me out. I had to make a few minor changes. Now the program looks like:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.text.DecimalFormat;
    public class DogsHumanAge extends JApplet
    implements ActionListener
    JTextField inputDogYears, displayHumanYears;
    public void init()
    JLabel labelDogYears = new JLabel("Enter the dog's age in dog years:",
    SwingConstants.RIGHT);
    inputDogYears = new JTextField(5);
    JLabel labelHumanYears = new JLabel("Human years = ", SwingConstants.RIGHT);
    displayHumanYears = new JTextField(5);
    displayHumanYears.setEditable(false);
    JButton go = new JButton("Compute age");
    go.addActionListener(this);
    Container c = getContentPane();
    c.setBackground(Color.white);
    JPanel p = new JPanel();
    p.setLayout(new GridLayout(3, 2, 5, 5));
    p.add(labelDogYears);
    p.add(inputDogYears);
    p.add(labelHumanYears);
    p.add(displayHumanYears);
    c.add(p, BorderLayout.CENTER);
    c.add(go, BorderLayout.SOUTH);
    public void actionPerformed(ActionEvent e)
    int dogYears = Integer.parseInt(inputDogYears.getText());
    double humanYears = calculateHumanYears(dogYears);
    DecimalFormat df = new DecimalFormat("00.0");
    displayHumanYears.setText(df.format(humanYears));
    private double calculateHumanYears(int dogYears)
    return 13 + (int)(16.0 / 3.0 * (dogYears - 1));
    Thanks to all that helped me!

  • Has anyone had the problem with their iPhone 5 where some people cannot receive texts from you?  And if so, is there a fix?

    Has anyone had the problem of not being able to send texts to certain people? 

    Here is another screenshot.  In this example, I did 'Get Info' on one of the goofy ones, and it shows that this Wolfmother song is sorted by the Eagles.  ***? 

  • Whats the problem with this page

    hi,
    i have problem with this page
    page
    it loading the video but not showing any content related to
    the video.
    i use
    [code]
    var netCon:NetConnection = new NetConnection();
    netCon.connect(null);
    var netStr:NetStream = new NetStream(netCon);
    netStr.addEventListener(AsyncErrorEvent.ASYNC_ERROR,
    getError);
    var video:Video = new Video();
    video.attachNetStream(netStr);
    addChild(video);
    video.x=201;
    video.y=125;
    function getError(e:AsyncErrorEvent) {
    play_btn.addEventListener(MouseEvent.MOUSE_DOWN, playVideo);
    function playVideo(e:MouseEvent) {
    netStr.resume();
    removeEventListener(KeyboardEvent.KEY_DOWN, keyPressHandler
    this.addEventListener(Event.ENTER_FRAME, fileLoaded);
    var loaderBar:Sprite = new Sprite();
    addChild(loaderBar);
    function fileLoaded(e:Event) {
    var percent:Number = (netStr.bytesLoaded * 100 ) /
    netStr.bytesTotal;
    loaderBar.graphics.clear();
    loaderBar.graphics.beginFill(0xDE2C18);
    loaderBar.graphics.drawRect(205,378,percent * 4.32,5);
    loaderBar.graphics.endFill();
    if (percent==100) {
    this.removeEventListener(Event.ENTER_FRAME, fileLoaded);
    [/code]

    here is the full code
    and i have an error saying:
    ArgumentError: Error #2004: One of the parameters is
    invalid.
    at flash.display::Graphics/drawRect()
    at VIDEOPLAYER_fla::MainTimeline/fileLoaded()
    [code]
    import flash.display.Sprite;
    import flash.net.NetConnection;
    import flash.display.SimpleButton;
    import flash.net.NetStream;
    import flash.events.NetStatusEvent;
    import flash.media.Video;
    import flash.events.MouseEvent;
    import flash.events.KeyboardEvent;
    import flash.events.Event;
    import flash.display.Graphics;
    import flash.text.*;
    var netCon:NetConnection = new NetConnection();
    netCon.connect(null);
    var netStr:NetStream = new NetStream(netCon);
    netStr.addEventListener(AsyncErrorEvent.ASYNC_ERROR,
    getError);
    var URL:String =
    "/hakans/videos/BEDUK_AUTOMATIK00.flv?start=";
    var offset:uint = 1048576;
    var tamURL:String = URL + offset;
    trace(tamURL);
    var video:Video = new Video();
    video.attachNetStream(netStr);
    video.x=201;
    video.y=125;
    netCon = new NetConnection();
    netCon.addEventListener(NetStatusEvent.NET_STATUS,
    netStatusHandler);
    netCon.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
    securityErrorHandler);
    function netStatusHandler(event:NetStatusEvent):void {
    switch (event.info.code) {
    case "NetConnection.Connect.Success":
    connectStream();
    break;
    case "NetStream.Play.StreamNotFound":
    trace("Unable to locate video: " + tamURL);
    break;
    function connectStream():void {
    netStr.addEventListener(NetStatusEvent.NET_STATUS,
    netStatusHandler);
    netStr.addEventListener(AsyncErrorEvent.ASYNC_ERROR,
    asyncErrorHandler);
    netStr.play(tamURL);
    addChild(video);
    function securityErrorHandler(event:SecurityErrorEvent):void
    trace("securityErrorHandler: " + event);
    function asyncErrorHandler(event:AsyncErrorEvent):void {
    // ignore AsyncErrorEvent events.
    function getError(e:AsyncErrorEvent) {
    var myTextBox:TextField = new TextField();
    var myText:String = "Bytes loaded";
    function TextWithImage()
    addChild(myTextBox);
    myTextBox.text = myText+netStr.bytesLoaded;
    /*--------------< Videoyu Durdurma, Oynatma ve Başa
    Alma >------------------*/
    stage.addEventListener( KeyboardEvent.KEY_DOWN,
    keyPressHandler );
    function keyPressHandler( e:KeyboardEvent ):void {
    // if the spaceBar is pressed then toggle video play/pause
    if( e.charCode == 32 ) {
    netStr.togglePause();
    play_btn.addEventListener(MouseEvent.MOUSE_DOWN, playVideo);
    function playVideo(e:MouseEvent) {
    netStr.resume();
    removeEventListener(KeyboardEvent.KEY_DOWN, keyPressHandler
    pause_btn.addEventListener(MouseEvent.MOUSE_DOWN,
    pauseVideo);
    function pauseVideo(e:MouseEvent) {
    netStr.pause();
    stop_btn.addEventListener(MouseEvent.MOUSE_DOWN, stopVideo);
    function stopVideo(e:MouseEvent) {
    netStr.pause();
    netStr.seek(0);
    fastforward_btn.addEventListener(MouseEvent.MOUSE_DOWN,doForward);
    function doForward(e:MouseEvent):void {
    var f:int = 1; //you can schange the skipping time here
    netStr.pause();
    netStr.seek(netStr.time + f);
    netStr.resume();
    rewind_btn.addEventListener(MouseEvent.MOUSE_DOWN,doRewind);
    function doRewind(e:MouseEvent):void{
    var x:int = 2;
    netStr.pause();
    netStr.seek(netStr.time - x);
    netStr.resume();
    fullscreen_btn.addEventListener(MouseEvent.MOUSE_DOWN,doFull);
    function doFull(e:MouseEvent):void{
    stage.displayState = StageDisplayState.FULL_SCREEN;
    /*--------------< Videoyu Durdurma, Oynatma ve Başa
    Alma / >------------------*/
    /*--------------< Video İçin Yükleme Bilgi
    Çubuğu >------------------*/
    var loaderBg:Sprite = new Sprite();
    loaderBg.graphics.beginFill(0xc78f8e);
    loaderBg.graphics.drawRect(205 , 378 , 430 , 5);
    loaderBg.graphics.endFill();
    addChild(loaderBg);
    this.addEventListener(Event.ENTER_FRAME, fileLoaded);
    var loaderBar:Sprite = new Sprite();
    addChild(loaderBar);
    function fileLoaded(e:Event) {
    var percent:Number = (netStr.bytesLoaded * 100 ) /
    netStr.bytesTotal;
    loaderBar.graphics.clear();
    loaderBar.graphics.beginFill(0xDE2C18);
    loaderBar.graphics.drawRect(205 , 378 , percent * 4.32 , 5);
    loaderBar.graphics.endFill();
    if (percent==100) {
    this.removeEventListener(Event.ENTER_FRAME, fileLoaded);
    /*--------------< Video İçin Yükleme Bilgi
    Çubuğu / >------------------*/
    /*--------------< Video Meta Bilgileri
    >------------------*/
    var metaObject:Object = new Object();
    netStr.client = metaObject;
    metaObject.onMetaData = getMetaInformation;
    var lengthOfVideo:Number = 0;
    function getMetaInformation(e:Object):void {
    lengthOfVideo = e.duration;
    trace("Genişlik :" + e.width);
    trace("Yükseklik :" + e.height);
    /*--------------< Video Meta Bilgileri /
    >------------------*/
    /*--------------< Videonun Durum Çubuğu
    >------------------*/
    //may cause problem part
    var GraphicsExample :Sprite = new Sprite();
    var size:uint = 10;
    var bgColor:uint = 0x999999;
    var borderColor:uint = 0x999999;
    var borderSize:uint = 0;
    var cornerRadius:uint = 9;
    var gutter:uint = 5;
    var dragBar:Sprite = new Sprite();
    var halfSize:uint = Math.round(size / 2);
    dragBar.graphics.beginFill(bgColor);
    dragBar.graphics.lineStyle(borderSize, borderColor);
    dragBar.graphics.drawCircle(halfSize, halfSize, halfSize);
    dragBar.graphics.endFill();
    dragBar.x=201;
    dragBar.y=376;
    addChild(dragBar);
    var drag:Boolean = false;
    this.addEventListener(Event.ENTER_FRAME, setDragBar);
    function setDragBar(e:Event) {
    if (!drag) {
    dragBar.x = ((netStr.time / lengthOfVideo) * 429) + 201;
    /*--------------< Videonun Durum Çubuğu /
    >------------------*/
    /*--------------< Videonun Kaydırma Çubuğu
    >------------------*/
    dragBar.addEventListener(MouseEvent.MOUSE_DOWN,
    startDragging);
    dragBar.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    dragBar.buttonMode = true;
    var rect:Rectangle = new Rectangle(205,378,429,0);
    function startDragging(e:MouseEvent) {
    drag = true;
    netStr.pause();
    dragBar.startDrag(false,rect);
    function stopDragging(e:MouseEvent) {
    dragBar.stopDrag();
    drag = false;
    netStr.resume();
    this.addEventListener(Event.ENTER_FRAME, reSetVideo);
    function reSetVideo(e:Event) {
    if (drag) {
    netStr.seek(Math.floor(((dragBar.x-201) / 429) *
    lengthOfVideo ));
    /*--------------< Videonun Kaydırma Çubuğu
    / >------------------*/
    netStr.addEventListener(NetStatusEvent.NET_STATUS,
    netStatusHandler1);
    function netStatusHandler1(e:NetStatusEvent):void
    switch (e.info.code)
    case "NetStream.Seek.InvalidTime":
    trace("You have seeked too far ahead, the video hasn't fully
    loaded yet");
    break;
    case "NetStream.Play.StreamNotFound":
    trace("Unable to locate video");
    break;
    /*--------------< Video Ses Kontrolü
    >------------------*/
    sound_btn.addEventListener(MouseEvent.MOUSE_DOWN, setSound);
    var checkSound:Boolean = true;
    var soundTrans:SoundTransform = new SoundTransform();
    function setSound(e:MouseEvent) {
    if (checkSound) {
    soundTrans.volume = 0;
    checkSound = false;
    } else {
    soundTrans.volume = 1;
    checkSound =true;
    netStr.soundTransform = soundTrans;
    /*--------------< Video Ses Kontrolü /
    >------------------*/
    [/code]

  • What is the problem with this code ? Race condition??

    Guys,
    The idea behind the attached code is quite simple.
    I have a 2D parent array. First, I print a subset of this array into a table control (based on a sensor selection). Now, I want edit the numbers in the table. I need the changes to be reflected in the table and the parent 2D array. (In simple terms, this is like replacing the the edited array subset into the parent 2D array)
    The problem is when I change(edit) any entry in the table, the entry changes back to its original value. The change doesnt seem to be reflecting on the parent 2D array and the table. .
    Can anyone tell me where the problem is?
    Thanks
    Ravi
    Solved!
    Go to Solution.
    Attachments:
    Alarm threshold test.vi ‏14 KB

    I agree with Chris, here's an idea (of whatI think your code does):
    The case structure in your code was unnecessary, all the cases were the same so I removed them.
    The sequence structure was unnecessary.
    Ton
    Message Edited by TonP on 11-20-2008 07:52 PM
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!
    Attachments:
    Alarm threshold test_BD.png ‏19 KB

  • Can anyone spot the problem?

    Hey i've been workin on an applet which accepts two boolean equations with 3 variables and returns an answer telling if they are logically equal. When it comes to the PLUS and MINUS cases the program works fine. However in the TIMES and DIVIDE cases it returns at least one wrong answer, despite the fact i'm using the logical AND gate. For example if i enter x*y the program returns
    answer 1 = O, when (x,y)=(0,0)
    answer 2 = 1, when (x,y)=(1,0)
    answer 3 = O, when (x,y)=(0,1)
    answer 4 = 1, when (x,y)=(1,1)
    were answer 2 is wrong using an AND gate.
    Here is the for loop which passes the values
                 for (int y = 0; y < 2; y++)
                   for (int x = 0; x < 2; x++)
                       int d = MyParser.answer(x, y);
                       int doub = MyParser2.answer(x, y);
                       String eq = "";
                       if (d == doub) {
                         equal++;
                         count++;
                         eq = "equal\t";
                       else {
                         count++;
                         eq = "not equal";
                       tb1.append("\nAnswer was " + d + "\t " + eq + " " +
                                  "\t answer 2 was " + doub);
                   }and here is the code for the parser
    package Applet1;
    public final class Parse
      public Parse (String equation)
        parse (equation);
       public int answer(int x,int y, int z)
         return this.value(x,y,z);
       public int answer(int x,int y)
         return this.value(x, y);
       public int answer(int x)
         return this.value(x);
       public int value(int x)
         return val(x, 0, 0);
       public int value(int x, int y)
         return val(x, y, 0);
       public int value(int x, int y, int z)
         return val(x, y, z);
       public String getEquation()
        return equation;
      private String equation;
      private byte[] code;
      private int[] stack;
      private int[] constant;
      private int pos = 0, constantCt = 0, codeSize = 0;
      private static final byte
      PLUS = -1,   MINUS = -2,   TIMES = -3,   DIVIDE = -4,
      UNARYMINUS = -5, VARIABLEX = -6, VARIABLEY = -7, VARIABLEZ = -8;
      private char next()
        if (pos >= equation.length())
        return 0;
        else
        return equation.charAt(pos);
      private void skip()
        while (Character.isWhitespace(next()))
        pos++;
      private int val(int variableX, int variableY, int variableZ)
       try
         int top = 0;
         for (int i=0; i < codeSize; i++)
           if (code[i] >= 0)
             stack [top++] = constant [code ];
    else if (code [i] >= UNARYMINUS)
    int y = stack[--top];
    int x = stack[--top];
    int w;
    int ans = (int) Double.NaN;
    switch (code[i])
    case PLUS: ans = x | y;
    break;
    case MINUS: ans = (x) & (~y);
    break;
    case TIMES: ans = x & y;
    break;
    case DIVIDE: ans = x & ~y;
    break;
    if (Double.isNaN(ans))
    return ans;
    stack [top++] = ans;
    else if (code[i] == VARIABLEX)
    stack [top++] = variableX;
    else if (code[i] == VARIABLEY)
    stack [top++] = variableY;
    else if (code[i] == VARIABLEZ)
    stack [top++] = variableZ;
    catch (Exception e)
    double b = Double.NaN;
    int i = (int) b;
    return i;
    double d2;
    if (Double.isInfinite(stack[0]))
    d2 = Double.NaN;
    int i2 = (int) d2;
    return i2;
    }else
    return stack[0];
    private void error (String message)
    throw new IllegalArgumentException
    ("Parse error: " + message + "\n");
    private int stackUse()
    int s = 0;
    int max = 0;
    for (int i = 0; i < codeSize; i++)
    if (code[i] >= 0 || code [i] == VARIABLEX || code[i] == VARIABLEY || code[i] == VARIABLEZ)
    s++;
    if (s > max)
    max = s;
    } else if (code[i] >= UNARYMINUS)
    s--;
    return max;
    private void parse (String equation)
    if (equation == null || equation.trim().equals(""))
    error ("No Data to be parsed");
    this.equation = equation;
    code = new byte[equation.length()];
    constant = new int [equation.length()];
    parseExpress();
    skip();
    int stackSize = stackUse();
    stack = new int[stackSize];
    byte[] c = new byte[codeSize];
    System.arraycopy(code,0,c,0,codeSize);
    code = c;
    int[] A = new int[constantCt];
    System.arraycopy(constant,0,A,0,constantCt);
    constant = A;
    private void parseExpress()
    boolean neg = false;
    skip();
    parseVaries();
    if (neg)
    code[codeSize++] = UNARYMINUS;
    skip();
    while (next() == '+' || next() == '-')
    char op = next();
    pos++;
    parseTerm();
    if (op =='+')
    code[codeSize++] = PLUS;
    else
    code[codeSize++] = MINUS;
    skip();
    private void parseTerm()
    parseFactor();
    skip();
    while (next() == '*' || next() == '/')
    char op = next();
    pos++;
    parseFactor();
    code[codeSize++] = (op == '*')? PLUS:MINUS;
    skip();
    private void parseFactor()
    parseVaries();
    skip();
    while (next() == '^')
    pos++;
    parseVaries();
    code[codeSize++] = UNARYMINUS;
    skip();
    private void parseVaries()
    skip();
    char ch = next();
    if (ch == 'x' || ch =='X')
    pos++;
    code[codeSize++] = VARIABLEX;
    else if (ch == 'y' || ch == 'Y')
    pos++;
    code[codeSize++] = VARIABLEY;
    else if (ch == 'z' || ch == 'Z')
    pos++;
    code[codeSize++] = VARIABLEZ;
    else if (ch == '(')
    pos++;
    parseExpress();
    skip();
    if (next () !=')')
    error("Right parenthesis needed");
    pos++;
    else if (ch == ')')
    error ("Need a left parenthesis");
    else if (ch == '+' || ch == '-' || ch == '*' || ch =='/' || ch =='^')
    error ("Operator" + ch + "\n found in unexpected position");
    else if (ch == 0)
    error ("Incorrect entry");
    else
    error ("Illegal character " + ch);
    Its not pretty i know and its missing a part to parse Digits and i'm using type casting for strange reasons, but it does work. Except for in these two cases, can anyone see why
    Thanks
    podger

    I'm not even entirely certain what you are trying to accomplish here.
    It looks wrong in any case.
    I can't see anything in the way of debugging, so heres my help for today:
    public void printCode(){
          System.out.println(equation + ":");
          for(int i=0; i<code.length; i++){
            switch(code){
    case PLUS: System.out.print("Plus "); break;
    case MINUS: System.out.print("Minus "); break;
    case TIMES: System.out.print("TIMES "); break;
    case DIVIDE: System.out.print("DIVIDE "); break;
    case UNARYMINUS: System.out.print("-"); break;
    case VARIABLEX: System.out.print("x "); break;
    case VARIABLEY: System.out.print("y ");break;
    case VARIABLEZ:System.out.print("z ");break;
    System.out.println();
    I suggest you parse a couple of expressions, and print out the code generated using this handy little method.
    Parse parse = new Parse("x+y");
    parse.printCode();       
    parse = new Parse("x*y");
    parse.printCode();(x+y) : x y Plus
    (x*y) : x
    I think you will find the problem in your parseExpress method (well one of your problems anyway)
    Also take a look at your ParseTerm function - I'm pretty sure that a * is meant to represent "TIMES" and not "PLUS"
    Did you ever thing about using switch statements rather than ifs?
    Good luck,
    evnafets

  • The installer has encountere​d an unexpected error installing this package. This may indicate the problem with this package. The error code is 2705.

    When I creat setup project in Visual Studio 2005 with only cvirte.msm merge module installer finish the unstallation successfully, however the program asks for MESA.DLL. When the NImesa.msm is added to the installation package the installer fails witht the error code 2705. The exact message is indicated as the "Subject".
    How can I overcome the problem?
    Solved!
    Go to Solution.

    Hi nikki7,
    Are you using a non-english operating system? If you are, then the KnowledgeBase article I included below should be helpful. I hope this helps!
    Error -2705 from the MSI Installer Built with the Visual Studio .NET Installation Builder: http://digital.ni.com/public.nsf/allkb/19CA3B8F15B​4FB9386256DDA006DFED8?OpenDocument
    Regards,
    Jason D
    Applications Engineer
    National Instruments

Maybe you are looking for

  • Intel graphics (945GM) and Kwin compositing not working.

    I've done upgrade few months ago, and ever since then kwin compositing simply refuses to work. I'm currently running Xorg 1.8.1.902, have tried almost everything i could find on this forum (even wen't and rebuiild everything from scratch), but proble

  • My code not give me result and error for move to next record please see

    hi master sir i import this file also import javax.faces.event.ValueChangeEvent; then my error remove i am use this code in button event getMfatableDataProvider().cursorNext(); form1.discardSubmittedValues("virtualForm1"); and my textField is bounded

  • Exporting vectors in RGB

    Okay, fairly simply I'm using Flash MX 2004 (v7.2) and have used it to draw a piece of vector artwork incorporating a lot of nice shading and a really beautiful blood-red colour. I now want to export the image to Photoshop for printing off in a large

  • Why always failure at 45% of install of Base System Part 1?

    Ok I have had Panther run on my iMac several times only to have it screw up and destroy itself hence reinstallation. However no matter what configuration I pick of Panther, It always either freezes up or kernel panics at precisely 45% of installation

  • Load cube data at multiple levels

    Hi All, I have a time dimension with following hierarchies. all_time --> Year --> Quarter -->Month all_time -->Week My fact table contains data at week and month level. I mapped my fact table time_key to both levels(Week and month) in AWM but when I