Class calling Problem

I am having a error
"Cannot reference this before supertype constructor has been called".
and have no clue what is trying to tell me. It goes to this code snid bit that i am working on for a test game i will be creating.
class Races
     public Races(Races r,boolean[] Race,int n)
          if(Race[0])
               r = new Human(r,Race,n);
          else if(Race[1])
               r = new Mincila(r,Race,n);
          else if(Race[2])
               r = new Deathoid(r,Race,n);
          else if(Race[3])
               r = new Mech(r,Race,n);
     class Human extends Races
          public Human(Races r,boolean[] Race,int n)
               super(r,Race,n);
          private void setBaseUnit(int n)
               switch(n)
                    case 1:
                         break;
                    case 2:
                         break;
          private class Warrior extends Human
               private int Health, AP, IMGnum;
               private String IMGname;
               private Image IMG;
               private int D_AP = 5, D_Health = 150;
               public Warrior(Races r,boolean[] Race,int n)
                    Health = getDefaultHealth();
                    AP = getDefaultAP();
                    IMGname = "Blazer";
                    IMGnum = 0;
                         IMG = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/Images/"+IMGname+"/"+IMGname+IMGnum+".gif"));
               private int getDefaultAP()
               {return D_AP;}
               private int getDefaultHealth()
               {return D_Health;}
          private class Mage extends Human
               private int Health, AP, IMGnum;
               private String IMGname;
               private Image IMG;
               private int D_AP = 5, D_Health = 150;
               public Mage(Races r,boolean[] Race,int n)
                    Health = getDefaultHealth();
                    AP = getDefaultAP();
                    IMGname = "Mage";
                    IMGnum = 0;
                    IMG = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/Images/"+IMGname+"/"+IMGname+IMGnum+".gif"));
               private int getDefaultAP()
               {return D_AP;}
               private int getDefaultHealth()
               {return D_Health;}
          private class Warlock extends Human
               private int Health, AP, IMGnum;
               private String IMGname;
               private Image IMG;
               private int D_AP = 5, D_Health = 150;
               public Warlock(Races r,boolean[] Race,int n)
                    Health = getDefaultHealth();
                    AP = getDefaultAP();
                    IMGname = "Warlock";
                    IMGnum = 0;
                    IMG = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/Images/"+IMGname+"/"+IMGname+IMGnum+".gif"));
               private int getDefaultAP()
               {return D_AP;}
               private int getDefaultHealth()
               {return D_Health;}
}can you please help me by telling me where my problem is coming in and how i can fix it. If this is a poor choice of codeing the program. and any other improvement that i could use.
null

ok nickmagus your program design worked you win the bucks but now i got some different problems and will be doing another 2 if someone can help me with this
I have made a test class
import java.awt.*;
public class BWTester
     public static void main(String args[])
          BWcharaters BWC = new BWcharaters("Human","Warrior");
          try{
               System.out.println("Race: "+BWC.getRace());
          }catch(Exception e){
               System.out.println("Race not obtained");
          try{
               System.out.println("Class: "+BWC.getClassName());
          }catch(Exception e){
               System.out.println("Class not obtained");
}A class to call it and run Races.. (Which has new name and face but works)
import java.awt.*;
import javax.swing.*;
import java.lang.*;
public class BWcharaters
     private boolean Human, Mincila, Deathoid, Mech, BROKEN;
     BWRaces r;
     public BWcharaters(String Race,String U_Class)
          setCharater(Race,U_Class);
     public String getRace()
          String Race = r.getRace();
          return Race;
     public String getClassName()
          String ClassName = r.getClassName();
          return ClassName;
     private void setCharater(String Race,String U_Class)
          boolean[] BWcB = new boolean[4];
          if(Race == "Human")
               BWcB[0] = true;
          else if(Race == "Mincila")
                BWcB[1] = true;
          else if(Race == "Deathoid")
               BWcB[2] = true;
          else if(Race == "Mech")
               BWcB[4] = true;
          r = new BWRaces(r,BWcB,U_Class);
}And Race itself
import java.awt.*;
class BWRaces
     protected String RaceName = null;
     protected String ClassName = null;
     public BWRaces(BWRaces r,boolean[] Race,String U_Class)
          setRace(r,Race,U_Class);
          ClassName = U_Class;
     public String getRace()
     {return RaceName;}
     public String getClassName()
     {return ClassName;}
     private void setRace(BWRaces r,boolean[] Race,String U_Class)
          if(Race[0])
               r = new Human(r,Race,U_Class);
               RaceName = "Human";
          else if(Race[1])
               r = new Mincila(r,Race,U_Class);
               RaceName = "Mincila";
          else if(Race[2])
               r = new Deathoid(r,Race,U_Class);
               RaceName = "Deathoid";
          else if(Race[3])
               r = new Mech(r,Race,U_Class);
               RaceName = "Mech";
class Human extends BWRaces
     public Human(BWRaces r,boolean[] Race,String U_Class)
          super(r,Race,U_Class);
          setBaseUnit(r,Race,U_Class);
     private void setBaseUnit(BWRaces r,boolean[] Race,String U_Class)
               if(U_Class == "Warrior")
                    r = new Warrior(r,Race,U_Class);
               else if(U_Class == "Mage")
                    r = new Mage(r,Race,U_Class);
               else if(U_Class == "Warlock")
                    r = new Warlock(r,Race,U_Class);
class Mincila extends BWRaces
     public Mincila(BWRaces r,boolean[] Race,String U_Class)
          super(r,Race,U_Class);
class Deathoid extends BWRaces
     public Deathoid(BWRaces r,boolean[] Race,String U_Class)
          super(r,Race,U_Class);
class Mech extends BWRaces
     private int Health;
     public Mech(BWRaces r,boolean[] Race,String U_Class)
          super(r,Race,U_Class);
class Warrior extends Human
     private int Health, AP, IMGnum;
     private String IMGname;
     private Image IMG;
     private int D_AP = 5, D_Health = 150;
     public Warrior(BWRaces r,boolean[] Race,String U_Class)
          super(r,Race,U_Class);
          Health = getDefaultHealth();
          AP = getDefaultAP();
          IMGname = "Blazer";
          IMGnum = 0;
          IMG = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/Images/"+IMGname+"/"+IMGname+IMGnum+".gif"));
     private int getDefaultAP()
     {return D_AP;}
     private int getDefaultHealth()
     {return D_Health;}
     public String getClassName()
          String ClassName = "Warrior";
          return ClassName;
class Mage extends Human
     private int Health, AP, IMGnum;
     private String IMGname;
     private Image IMG;
     private int D_AP = 5, D_Health = 150;
     public Mage(BWRaces r,boolean[] Race,String U_Class)
          super(r,Race,U_Class);
          Health = getDefaultHealth();
          AP = getDefaultAP();
          IMGname = "Mage";
          IMGnum = 0;
          IMG = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/Images/"+IMGname+"/"+IMGname+IMGnum+".gif"));
     private int getDefaultAP()
     {return D_AP;}
     private int getDefaultHealth()
     {return D_Health;}
class Warlock extends Human
     private int Health, AP, IMGnum;
     private String IMGname;
     private Image IMG;
     private int D_AP = 5, D_Health = 150;
     public Warlock(BWRaces r,boolean[] Race,String U_Class)
          super(r,Race,U_Class);
          Health = getDefaultHealth();
          AP = getDefaultAP();
          IMGname = "Warlock";
          IMGnum = 0;
          IMG = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/Images/"+IMGname+"/"+IMGname+IMGnum+".gif"));
     private int getDefaultAP()
     {return D_AP;}
     private int getDefaultHealth()
     {return D_Health;}
}If you could seriously help me figure out what the probelm java is having with me it would help a ton. To check you need to Copy and paste my programs in 3 files and then run BWTester.
It will pop up with a ton of
at BWRaces.setRace<BWRaces.java:20>
at BWRaces.<init><BWRaces.java:9>
at Human.<init><BWRaces.java:45>

Similar Messages

  • Inheritance problem with parent class calling child class

    I have a problem with inheritance with a parent class calling a child class method. Below is the example pseudocode code and my problem:
    public abstract class A {
        protected void function1 ( ) { }
        protected void function2 () {
             //calls function1();
             function1();
    public abstract class B extends A {
        protected void function1 ()  {
             // do stuff
    public class C extends B {
        protected void function1 ()  {
            // do stuff
            super.function1 ();
    }I have an object instance of class C created and its function2() is invoked.
    My problem is, while in function2(), which belongs to abstract class A and the method call to function 1() is called, the call invokes the function1() of class B. Shouldn't the call invoke function 1() of class C instead? And then function1() of class B will be called after due to the super.function1(). It's not behaving like I thought it would.
    Edited by: crono77 on Jan 10, 2008 8:13 PM

    Nevermind, i found my error :)

  • Sequence of classes called in a badi

    Hi guys,
    I have a problem on the sequence of the classes called in a standard BADI occuring in different system.
    In the DEV system, the sequence called is A, B, C (Just to illustrate). But, in the QA and PROD system, the sequence called is B, C, A. Versions of each objects have been compared and found to be the same.
    Any ideas how to solve this?
    Thanks!

    Hi guys,
    I have a problem on the sequence of the classes called in a standard BADI occuring in different system.
    In the DEV system, the sequence called is A, B, C (Just to illustrate). But, in the QA and PROD system, the sequence called is B, C, A. Versions of each objects have been compared and found to be the same.
    Any ideas how to solve this?
    Thanks!

  • Sequence of the classes called in a standard BADI

    Hi guys,
       I have a problem on the sequence of the classes called in a standard BADI occuring in different system.
       In the DEV system, the sequence called is A, B, C (Just to illustrate). But, in the QA and PROD system, the sequence called is B, C, A. Versions of each objects have been compared and found to be the same.
       Any ideas how to solve this?
       Thanks!

    Hi Ndruzz,
    Every BADI by default Implements an INTERFACE which already contains some methods with parameters.
    So you have to find the relavenet method based on the related paramters (by checking the fields in that paramters) you have to double click on the method and to write the code.
    see the doc
    DEFINING THE BADI
    1) execute Tcode SE18.
    2) Specify a definition Name : ZBADI_SPFLI
    3) Press create
    4) Choose the attribute tab. Specify short desc for badi.. and specify the type :
    multiple use.
    5) Choose the interface tab
    6) Specify interface name: ZIF_EX_BADI_SPFLI and save.
    7) Dbl clk on interface name to start class builder . specify a method name (name,
    level, desc).
    Method level desc
    8) place the cursor on the method name desc its parameters to define the interface.
    Parameter type refe field desc
    I_carrid import spfli-carrid some
    I_connid import spefi-connid some
    9) save , check and activate…adapter class proposed by system is
    ZCL_IM_IM_LINESEL is genereated.
    IMPLEMENTATION OF BADI DEFINITION
    1) EXECUTE tcode se18.choose menuitem create from the implementation menubar.
    2) Specify aname for implementation ZIM_LINESEL
    3) Specify short desc.
    4) Choose interface tab. System proposes a name fo the implementation class.
    ZCL_IM_IMLINESEL which is already generarted.
    5) Specify short desc for method
    6) Dbl clk on method to insert code..(check the code in “AAA”).
    7) Save , check and activate the code.
    Some useful URL
    http://www.esnips.com/doc/e06e4171-29df-462f-b857-54fac19a9d8e/ppt-on-badis.ppt
    http://www.esnips.com/doc/10016c34-55a7-4b13-8f5f-bf720422d265/BADIs.pdf
    http://www.esnips.com/doc/43a58f51-5d92-4213-913a-de05e9faac0d/Business-Addin.doc
    http://www.esnips.com/doc/1e10392e-64d8-4181-b2a5-5f04d8f87839/badi.doc
    www.sapgenie.com/publications/saptips/022006%20-%20Zaidi%20BADI.pdf
    http://www.sapdevelopment.co.uk/enhance/enhance_badi.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/04/f3683c05ea4464e10000000a114084/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/e6/d54d3c596f0b26e10000000a11402f/content.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/c2/eab541c5b63031e10000000a155106/frameset.htm
    Now write a sample program to use this badi method..
    Look for “BBB” sample program.
    “AAA”
    data : wa_flights type sflight,
    it_flights type table of sflight.
    format color col_heading.
    write:/ 'Flight info of:', i_carrid, i_connid.
    format color col_normal.
    select * from sflight
    into corresponding fields of table it_flights
    where carrid = i_carrid
    and connid = i_connid.
    loop at it_flights into wa_flights.
    write:/ wa_flights-fldate,
    wa_flights-planetype,
    wa_flights-price currency wa_flights-currency,
    wa_flights-seatsmax,
    wa_flights-seatsocc.
    endloop.
    “BBB”
    *& Report ZBADI_TEST *
    REPORT ZBADI_TEST .
    tables: spfli.
    data: wa_spfli type spfli,
    it_spfli type table of spfli with key carrid connid.
    *Initialise the object of the interface.
    data: exit_ref type ref to ZCL_IM_IM_LINESEL,
    exit_ref1 type ref to ZIF_EX_BADISPFLI1.
    selection-screen begin of block b1.
    select-options: s_carr for spfli-carrid.
    selection-screen end of block b1.
    start-of-selection.
    select * from spfli into corresponding fields of table it_spfli
    where carrid in s_carr.
    end-of-selection.
    loop at it_spfli into wa_spfli.
    write:/ wa_spfli-carrid,
    wa_spfli-connid,
    wa_spfli-cityfrom,
    wa_spfli-deptime,
    wa_spfli-arrtime.
    hide: wa_spfli-carrid, wa_spfli-connid.
    endloop.
    at line-selection.
    check not wa_spfli-carrid is initial.
    create object exit_ref.
    exit_ref1 = exit_ref.
    call method exit_ref1->lineselection
    EXPORTING
    i_carrid = wa_spfli-carrid
    i_connid = wa_spfli-connid.
    clear wa_spfli.

  • "1046: Type was not found" for a custom class calling a custom class

    This should be easy... but I've spent two days on nothing but this error.... I am absolutely at my wit's end.
    Basically, I've got a "character" container linked to a MovieClip in the library that is supposed to act as a container for various body parts; head, shirt, pants, etc. For simplicity, I've just got Character class and Head class, both in a "char" package, both classes are named the same as their respective files (Character.as and Head.as, both in an actual file called "char"). Character class is supposed to create an instance of Head, but I always get this 1046 error. The problem is that I've got other body parts with nearly identical classes that ARENT throwing a 1046 error and are working just fine. I went and made a new project to see if I was still having the problem with just character calling 1 simple body part. I do.
    In the symbol properties, it's Exported for Actionscript & Export in Frame 1... the class is "char.Head" and "char.Character" respectively. I have tried everything I can find or think of, I've done dozens of Google searches and sifted through dozens of forums. I can't find anything and I've been working on this problem for 24 straight working hours now. I'm completely exasperated......
    package char {
    import flash.display.MovieClip;
    import flash.display.Stage;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.geom.ColorTransform;
    import fl.motion.Color;
    import char.Head;
    public class Character extends MovieClip {
    // 1046: Type was not found or was not a compile-time constant: Head
    private var _head:Head;
    // reference to get the stage later
    private var stageRef:Stage;
    public function Character(stageRef:Stage=null) {
    trace("NEW CHARACTER");
    //1180 Call to a possibly undefined method Head;
    _head=new Head();
    And here's the contents of Head.as
    package char {
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.display.Stage;
    import flash.geom.ColorTransform;
    public class Head extends MovieClip {
    private var skin_type:uint;
    public function Head() {
    trace ("NEW HEAD");
    Now if I declare the head variable and create a new instance of it in my document class, no problem whatsoever. If I do it in my Character class, it just doesn't stop giving me this error!!! Somebody please help me.
    1046: Type was not found or was not a compile-time constant: Head
    1180 Call to a possibly undefined method Head;

    There is a blank movieclip named Character in the library, yup.
    Also in my main handler for my document class calls "mainCharacter = new Character(); "
    Here's a chunk of the code from the document class. For the record, it calls "head" as just a test and that works fine. Just doesn't work in "Character"
    import char.Character;
    import char.Head;
    public class MainHandler extends MovieClip {
    private static var _instance:MainHandler;
    public static function get instance():MainHandler { return _instance; }
    public var mainCharacter:Character;
    public var head_:Head;
    public function MainHandler() {
    _instance = this;
    mainCharacter = new Character();
    head_=new Head();

  • Standard B2C application Order page Java class called on Update?

    Hi All,
    On the Standard B2C application, on adding CampaignKey to the order or Changing the Quantity of the Items. We click UPDATE to update the sales order.
    Please can anyone help to find out which JAVA action Class is linked with the Update button.
    I need to create one Z java action class to update the order.
    Thanks a lot!
    Ekta

    Hi
    I used session logging to trace the class called. I am not able to use HTTP Watch. It is on the Client's network using Citrix. Hence cannot install it. but no doubt that is a better way.
    Classes and the action path is
    main java action class 
    MaintainBasketB2CDispatcherAction"
    linked action path for Update is
    Action path="/b2c/maintainBasket"
    Forward path name   
    <forward name="update" path="/b2c/basketupdate.do"/>
    and for action path
    action path="/b2c/basketupdate"
    java action class :
    MaintainBasketB2CUpdateAction"
    I am making Z action claa for MaintainBasketB2CUpdateAction" and i am updating the condig.xml file.
    I am making this thread open. To trace the flow if in case i get some problem
    Thanks to all of you for your support!
    Thanks
    Ekta

  • Class Package Problem

    I have a class called Vertex, and a class called Matrix, They are both in the same package (maths3d). However, Matrix uses Vertex as part of its internal representation (array of Vertex). The problem lies in that, Matrix cannot deffine symbol Vertex.
    I thought classes where supposed to be usable by other classes in the same package? any help pls?
    Cheers
    Cata

    Package Vertex:
    package maths3d;
    public class Matrix {
         private Vertex[] matrix;
         private int Size;
         public Matrix(int Size) {
              this.Size = Size;
              matrix = new Vertex[Size*Size];
         public Matrix(Vertex[] M) {
              Size = (int)Math.sqrt(M.length);
              matrix = M;
         public int size () {
              return Size;
         public Vertex getRow(int row) {
              return matrix[row];
         public double get(int row, int col) {
              return matrix[row].get(col);
         public void set(int row, int col, double O) {
              matrix[row].set(col,0);
    }Package Matrix:
    package maths3d;
    public class Matrix {
         private Vertex[] matrix;
         private int Size;
         public Matrix(int Size) {
              this.Size = Size;
              matrix = new Vertex[Size*Size];
         public Matrix(Vertex[] M) {
              Size = (int)Math.sqrt(M.length);
              matrix = M;
         public int size () {
              return Size;
         public Vertex getRow(int row) {
              return matrix[row];
         public double get(int row, int col) {
              return matrix[row].get(col);
         public void set(int row, int col, double O) {
              matrix[row].set(col,0);
    }Still don't get it.
    What's the deal?

  • How to populate CONTROLLER in proxy class call?

    Hi All
    While calling proxy class, i want to populate input variable CONTROLLER. I want to use the method GET_MESSAGE_ID to get the message guid.
    CONTROLLER is TYPE REF TO IF_AI_POSTING_CONTROLLER.
    How can i get this populated thru my proxy class call? 
    Sample code is highly appreciated.
    Thanks
    Chandra

    Can you let me know little bit more details. Is this server proxy? If yes, you can use the proxy access class CL_PROXY_ACCESS to access the runtime variables of the proxy. Check http://help.sap.com/saphelp_nw70ehp1/helpdata/en/51/d5cd16235e4643ae8ec92395c4ad97/frameset.htm
    Controller is used for controlling the attributes of the message, say for example controlling initial values for fields etc.
    Let me know if you need more info.
    KK

  • I am an iphone4 user from United Arab Emirates with home button/MIC not working during call problems..

    hi, i am an iphone4 user from the United Arab Emirates. I got my phone as a gift last September and it was not bundled with any carriers and was a factory unlocked piece. Within one month of usage the home button started misfunctioning. It started registering double clicks as single, triple clicks, etc. (the usual complaint of many countless users of iphone from the time of the release.) I then kind of ignored this problem and continued using the phone.
    With this problem still continuing, comes another one.
    My friend gave me a call yesterday, and we were talking happily for a minute or so and suddenly without any reason my friend failed to hear me. Five minutes was spent trying to make myself heard to him. I tried and i tried and the only solution i could find was tapping the phone gently,but firmly. Then he was able to hear me but then after sometime it was back to the same problem.
    The only solution i found was to tap in th sides.(please note that this is also a common problem with many who have call problems but no voice memo problems.) I tried adding and registering my device to my account but when i try to put in my iphone's serial number,they say that the device number is invalid.
    Now i want to get a solution to this, but since this was a gift piece i do not have any invoice of any sort. I even checked itunes.com/support and was happy to find i still have warranty till september.
    I am confused as to what to do as I was dissappointed to find even a single apple store in the UAE and do not know what do we get in terms of support. Could someone please help me?

    that is exactly the problem. I have no idea as in where this phone originates from. It was gifted to my Dad from a personnel who he was supplying for in the company. My dad then gifted it to me on my birthday. I asked my dad about the phone but he also does not know a thing. He also said that the other guy must have taken the invoice with him as he did not give anything to my dad.
    I checked it in quite a few places (like SharafDG,eMax,Axiom etc., the local electronics suppliers) to track where this phone was originally purchased from( because these people usually take down the IMEI's of the electronic devices they sell), but they all could not help me.
    Now i have no idea what to do and i do not want to spend huge amounts of cash for this matter as i am already in the warranty period. Anyways,thanks for your help in advance, but it would be helpful if you could try to get this solved for me.

  • Class Importing Problem

    Dear all,
    could you know how to cheak a class is defined in JSP or not ?
    for example, I made a class called "staff" and import it in other page
    so, how to check the "staff" is imported ?
    Thanks,
    Jack.

    Hi 6z-SF
    If u have created a class and imported it into a JSP, then the best way to do what u want is, create a servlet(.class) and import ur class into it.
    Now compile the servlet.
    If it compiles without errors, it means that the class was imported successfully.
    Hope this helps.
    Cheers !!
    Sherbir

  • RMI class file problem

    I have already write a RMI example for self-study successfully, but there are a little class file problem that I'm not able fix it.
    In my RMI example there are 3 .java files (RMIServer.java, RMIClient.java and a MethodImpl.java)
    After I have javac and rmic them, I got RMIServer_Skel.class, RMIServer_Stub.class, RMIClient.class and the MethodImpl.class
    In order to run the RMI in a local envirnment, I divide them into 2 folders as listed below:
    Server - RMIServer_Skel.class, RMIServer_Stub.class and the MethodImpl.class
    Client - RMIServer_Stub.class, RMIClient.class and the MethodImpl.class
    Then when I start to run them in a DOC envirnment...
    start rmiregistry........(run successful and another rmiregistry DOC window created)
    java RMIServer.........Exception in thread "main" java.lang.NoClassDefFoundError: RMIServer
    Oops? Class not found? How can that be? And after that, I tried something.......to add the RMIServer.class into the Server folder.
    Again, I start to run them in a DOC envirnment...
    start rmiregistry........(run successful and another rmiregistry DOC window created)
    java RMIServer.........The server is instantiated(run successful and print out a String)
    Um...is the RMI have to run with a RMIServer.class file? But the RMI notes I refered from is not seems to be telling me to do this, are there any one can give me a helping hand?

    please, go here, read thoroughly
    http://java.sun.com/docs/books/tutorial/getStarted/cupojava/index.html

  • One Class Calling Another Class ......Need Help..ugh

    this is the class that calls another class called cuboid
    package WindowsApplication1;
    * Summary description for Cuboid.
    //Import the classes to allow the use of the array, iterator and listiterator
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.ListIterator;
    public class DisplayCuboidValues
         public static void main(String args[])
              //Create the array list
              ArrayList VolumeList = new ArrayList();
              //Create the counter to loop 4 times and get 4 different volumes. Modify the counter
              //if you need a different values
              int Counter = 1;
              //Initialize the counter to loop 4 times in order to get the 4 objects
              while (Counter < 5)
                   Cuboid mp = new Cuboid(2, 4, 3);
                   //Add the values to the array
                   VolumeList.add(mp);
                   // get the volume again via accessor method(Optional)
                   //int Volume = mp.Volume();
                   //System.out.println(Volume);
                   //Increment the counter to obtain a new value in the array
                   Counter = Counter + 1;
              // Retrieve iterator to the radiuslist
              Iterator itr1 = VolumeList.iterator();
              while (itr1.hasNext())
              // call Cuboid.toString()
              System.out.print(itr1.next());
              System.out.println();
    }this is the cuboid class
    package WindowsApplication1;
    * Summary description for Cuboid.
    public class Cuboid
         private final int length, width, height;
         //1st contructor with 3 arguments
         public Cuboid(int length, int width, int height)
              this.length = length;
              this.width = width;
              this.height = height;
         //2nd constructor with no arguments
    //I BELIEVE THIS PUBLIC CUBOID IS THE ONE THE PROVOKES THE ERROR. BUT I CAN NOT DELETE IT BECAUSE I NEED ANOTHER PUBLIC CUBOID. SO IDK WHAT TO DO......
         public Cuboid()
              this.length = length;
              this.width = width;
              this.height = height;
            public String toString() {
                   return "This cuboid has length x, width y, height z, and has volume of v where X=" + length + " " + "Y=" + width + " " + "Z=" + height + " " + "Volume=" + length * width * height + ".   --   ";
         //Method to calculate the Volume
         public int Volume()
              return length * width * height;
         }This is what i have done. I have created a project named ths(which i do not use it at all). Then, i created one file called DisplayCuboidValues under ths. Then i created the file Cuboid under ths too. But it gives me errors. like this one:
    init:
    deps-jar:
    Created dir: C:\Documents and Settings\Owner\ths\build\classes
    Compiling 1 source file to C:\Documents and Settings\Owner\ths\build\classes
    C:\Documents and Settings\Owner\ths\src\DisplayCuboidValues\Cuboid.java:25: variable length might not have been initialized
    this.length = length;
    *^*
    C:\Documents and Settings\Owner\ths\src\DisplayCuboidValues\Cuboid.java:26: variable width might not have been initialized
    this.width = width;
    *^*
    C:\Documents and Settings\Owner\ths\src\DisplayCuboidValues\Cuboid.java:27: variable height might not have been initialized
    this.height = height;
    *^*
    Note: C:\Documents and Settings\Owner\ths\src\DisplayCuboidValues\DisplayCuboidValues.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    *3 errors*
    BUILD FAILED (total time: 0 seconds)
    Any help you can give me will be appreciated. Thanks.

    yeah. you are right in that. so that means that i have to get rid of it??. because i will need it. and the values assigned to them is in the first class that calls the second class look:
    package WindowsApplication1;
    * Summary description for Cuboid.
    //Import the classes to allow the use of the array, iterator and listiterator
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.ListIterator;
    public class DisplayCuboidValues
         public static void main(String args[])
              //Create the array list
              ArrayList VolumeList = new ArrayList();
              //Create the counter to loop 4 times and get 4 different volumes. Modify the counter
              //if you need a different values
              int Counter = 1;
              //Initialize the counter to loop 4 times in order to get the 4 objects
              while (Counter < 5)
    *//HERE IS WHERE I AM PROVIDING THE OTHER CLASS WITH VALUES. THEREFORE IT SHOULD SENT THOSE VALUES TO MY CLASS CUBOID AND RETRIEVE THE ANSWER TO FOLLOW THE REST OF THIS CODE.*
                   Cuboid mp = new Cuboid(2, 4, 3);
                   //Add the values to the array
                   VolumeList.add(mp);
                   // get the volume again via accessor method(Optional)
                   //int Volume = mp.Volume();
                   //System.out.println(Volume);
                   //Increment the counter to obtain a new value in the array
                   Counter = Counter + 1;
              // Retrieve iterator to the radiuslist
              Iterator itr1 = VolumeList.iterator();
              while (itr1.hasNext())
              // call Cuboid.toString()
              System.out.print(itr1.next());
              System.out.println();
    }

  • Debug java class called from CF?

    I'm experiencing different behaviour with a Java class called from a CF page to the same class called directly from Java code.
    Is it possible for me to step into the Java class and debug it in CF builder if I attach the correct Java source?
    Pressing F5 (step-in) on the line that the method is called just skips straight over.
    Regards,
    Andy

    P5music wrote:
    I would like to be able to make a java application that has a GUI that is a rich web page.That's what applets are for.
    In this case, this page exists on my system and I can open it with my browser.
    This page does many things that are typical of a web page like displaying information and presenting rich and graphical controls
    but some of this controls are connected to a java application, launched from the web page or viceversa.I don't get this "launched from the web page" business. Is that a requirement or are you describing an existing system? Or are you describing somebody else's system whose architecture you want to imitate? Or are you using the word "launched" simply to describe the action of starting an applet?
    It still isn't clear to me what you are trying to describe. But at any rate if you want a Java program to run in your browser, that's an applet. Note that applets can interact with Javascript code in the page they are embedded in. Or if you want to download a Java application which acts as a separate application, i.e. it still runs when the browser is closed, you can use Web Start for that.

  • Nokia 6500 call problem

    Hello.
    I have owned a Nokia 6500 slide on the 3 network for just over a year now, it's a decent phone and I've had very few problems with it until recently. The current problem is that when I make or receive a call, there is no audio/volume. Once the call begins to ring or I answer, and it's connected, there is no volume. However, if I change it to loudspeaker, it can be heard perfectly normally as if it were played through loudspeaker (obviously). So in short, the "handset" option of the call is muted. I have checked the obvious thing such as settings and makings sure the call volume was high enough, but there is just no sound at all when on the handset setting of a call. To make a personal call I have to make it in loudspeaker and everyone can hear.
    I also had a problem wiht my contacts, and I downloaded the latest firmware and it fixed that problem. However, the loudspeaker call problem has remained. Usual searching hasn't sufficed, I appear to be the only one wiht this problem. Hopefully somebody can help me out here.
    Thanks in advance,
    Cams

    Take it to the nearest Nokia Care Point. Probably your speaker is damaged.
    Cheers,
    DeepestBlue
    5800 XpressMusic (Rock Stable) | N73 Music Edition (Never Say Die) | 1108 (Old and faithful)
    If you find any post useful, click on the Green "Kudos" Button on the left to say Thank You...

  • Java Class calling another class?

    i have a class called infix and a separate class called postfix. what i am trying to do is make the infix class create a string of postfix notation and then call the postfix class to do the computation.
    i have the string all ready to be passed to the postfix class for computation..my question is...how do i get it to that class?

    HERE ARE THE TWO CLASSES. THE POSTFIX WORKS FOR SURE AND I AM TRYING TO GET THE INFIX TO WORK. THE QUESTION IS IN THE RETURN OF THE INFIX. DONT TRY TO CORRECT THE INFIX CODE. I AM WORKING ON THAT BY MYSELF. I JUST NEED HELP ON CONNECTING THEM IF POSSIBLE. CHECK THE RETURN OF INFIX. THANKS ALOT
    import java.util.*;
    public class PostFix
         private Set<String> ops = new HashSet<String>();
         private List<String> lst = new LinkedList<String>();
         private static Map<String, String> m = new HashMap<String, String>();
         public List<String> getLst()
              return lst;
         public Map<String, String> getMap()
              return m;
         public PostFix( String s )
              ops.add("+");
              ops.add("-");
              ops.add("*");
              ops.add("/");
              ops.add("%");
              StringTokenizer sTok = new StringTokenizer(s);
              while( sTok.hasMoreTokens() )
                   lst.add( sTok.nextToken() );
              m.put( "a" , "26" );
              m.put( "b" , "25" );
              m.put( "c" , "24" );
              m.put( "d" , "23" );
              m.put( "e" , "22" );
              m.put( "f" , "21" );
              m.put( "g" , "20" );
              m.put( "h" , "19" );
              m.put( "i" , "18" );
              m.put( "j" , "17" );
              m.put( "k" , "16" );
              m.put( "l" , "15" );
              m.put( "m" , "14" );
              m.put( "n" , "13" );
              m.put( "o" , "12" );
              m.put( "p" , "11" );
              m.put( "q" , "10" );
              m.put( "r" , "9" );
              m.put( "s" , "8" );
              m.put( "t" , "7" );
              m.put( "u" , "6" );
              m.put( "v" , "5" );
              m.put( "w" , "4" );
              m.put( "x" , "3" );
              m.put( "y" , "2" );
              m.put( "z" , "1" );
         public int Value()
              Stack<Integer>operandStack = new Stack<Integer>();
              Iterator<String> iterator = lst.iterator();
              String tmp;
              int val1 = 0;
              int val2 = 0;
              int tmpInt = 0;
              while( iterator.hasNext() )
                   tmp = iterator.next();
                   if( !ops.contains( tmp ) )
                        operandStack.push(Integer.parseInt(tmp));
                   else
                        val1 = operandStack.pop();
                        val2 = operandStack.pop();     
                        Character c = new Character( tmp.charAt(0) );
                        switch( c )
                             case '+':
                                  operandStack.push(val1 + val2);
                                  break;
                             case '-':
                                  operandStack.push(val2 - val1);
                                  break;
                             case '*':
                                  operandStack.push(val1 * val2);
                                  break;
                             case '/':
                                  operandStack.push(val2 / val1);
                                  break;
                             case '%':
                                  operandStack.push(val2 % val1);
                                  break;
              return operandStack.peek();
         public int Value( Map m )
              Stack<Integer> operandStack = new Stack<Integer>();
              Iterator<String> iterator = lst.iterator();
              String tmp;
              String x;
              int val1 = 0;
              int val2 = 0;
              int tmpInt = 0;
              while( iterator.hasNext() )
                   tmp = iterator.next();
                   if( !ops.contains( tmp ) && !m.containsKey( tmp )  )
                        operandStack.push(Integer.parseInt(tmp));
                   else if ( !ops.contains(tmp) && m.containsKey(tmp) )
                        x = m.get(tmp).toString();
                        operandStack.push(Integer.parseInt(x));
                   else{          
                        val1 = operandStack.pop();
                        val2 = operandStack.pop();     
                        Character c = new Character( tmp.charAt(0) );
                        switch( c )
                             case '+':
                                  operandStack.push(val1 + val2);
                                  break;
                             case '-':
                                  operandStack.push(val2 - val1);
                                  break;
                             case '*':
                                  operandStack.push(val1 * val2);
                                  break;
                             case '/':
                                  operandStack.push(val2 / val1);
                                  break;
                             case '%':
                                  operandStack.push(val2 % val1);
                                  break;
              return operandStack.peek();
         and the infix is
    import java.util.*;
    public class InFix
         PostFix pFix;
         private Set<String> LowOps = new HashSet<String>();
         //private Set<String> parenthesis = new HashSet<String>();
         private Set<String> HighOps = new HashSet<String>();
         private List<String> lst = new LinkedList<String>();
         public List<String> getLst()
              return lst;
         public InFix( String s )
              LowOps.add("+");
              LowOps.add("-");
              HighOps.add("*");
              HighOps.add("/");
              //ops.add("%");
              StringTokenizer sTok = new StringTokenizer(s);
              while( sTok.hasMoreTokens() )
                   lst.add( sTok.nextToken() );
         public int Value()
              Stack <String> operatorStack = new Stack<String>();
              Iterator<String> iterator = lst.iterator();
              String tmp = "";
              String pFixStr = "";
              while( iterator.hasNext() )
                   tmp = iterator.next();
                   if( tmp == "(" )
                        operatorStack.push(tmp);
                   else if( tmp == ")" )
                        String peektmp = operatorStack.peek();
                        while( peektmp != "(" )
                             pFixStr.concat(operatorStack.pop() );
                   else if( !LowOps.contains(tmp) && !HighOps.contains(tmp) )//pushes if its a number
                        pFixStr.concat( tmp );
                   else if( LowOps.contains( tmp ) )
                        operatorStack.push(tmp);
                   else if( HighOps.contains( tmp ) )
                        operatorStack.push(tmp);
              while ( !operatorStack.empty() )
                   pFixStr.concat(operatorStack.pop());
              System.out.println( pFixStr );
         return <THIS IS WHERE I WANT TO RETURN THE COMPUTATION FROM THE POSTFIX CLASS. IS THIS CORRECT TO TRY AND RETURN A POSTFIX(PFIXSTR) OR SOMETHING LIKE THAT>     
         }THANKS

Maybe you are looking for