Constructor problems

>
1. Create an integer to hold the suit of the card. You can use the constants that have been defined for you to represent the four suits, hearts, spades, clubs and diamonds.
2. Create an integer to hold the rank of the card. A card's rank is a number from 1 to 13 with 1 being an ace and 13 being a king.
3. The constructor for the Card class has a single parameter which is an integer between 0 and 51 (inclusive). You should initialise the suit and rank from the parameter whose
value is interpreted as follows; 0 represents the ace of hearts, 1 represents the 2 of hearts,. . . , 12 represents the king of hearts, 13 represents the ace of clubs, 14 represents the two of clubs, . . . , 25 represents the king of clubs, 26 represents the ace of diamonds, 27 represents the two of diamonds, . . . , 38 represents the king of diamonds, 39 represents
the ace of spades, 40 represents the two of spades, . . . , 51 represents the king of spades.
My code so far ( it doesnt work, im just trying to get my head around what i need to do)
public class Card
    // Don't change these four constants
    private static final int HEARTS = 1;
    private static final int CLUBS = 2;
    private static final int DIAMONDS = 3;
    private static final int SPADES = 4;
    // write the your code below this line...
    //Holds suit of card
    private int suit = hearts, spades, clubs, diamonds;
    //Holds rank of card
    private int rank = 1,2,3,4,5,6,7,8,9,10,11,12,13;
     * Constructor
    public Card(int amount)
            0 == aceOfHearts;
            1 == 2OfHearts;
            12 == kingOFHearts;
            13 == aceOfClubs;
            14 == 2OfClubs;
            25 == kingOfClubs;
            26 == aceOfDiamonds;
            27 == 2OfDiamonds;
            38 == kingOfDiamonds;
            39 == aceOfSpades;
            40 == 2OfSpades;
            51 == kingOfSpades;
}I dont get this part *"You should initialise the suit and rank from the parameter whose value is interpreted as follows..."* the rank has already been intialised to a number from 1 to 13 right? how to i intialise both the rank and suit together?

CheekyChop wrote:
haha id say i wish he didnt make the first part of the assignment so tricky to understand the rest of it looks fine!
could anyone provide some pseudo code?
is this anywhere near right
public Card(int result)
mySuit = suit[result];
myRank = rank[result];
}Edited by: CheekyChop on Nov 16, 2008 1:49 PMThat's not how I would do it. If you read my post above...
Dividing that number in the constructor by the number of card values (13) will give you a number (0 to 3) representing the suit of the card, and the remainder from that division will give you the card value. ;-)... you might get something like this...
public Card(int value)
   suit = value / 13; //0=hearts, 1=clubs, 2=diamonds, 3=aces
   rank = value % 13; //the remainder of value/13; a number from 0 to 12
}Edited by: chickenmeister on Nov 16, 2008 8:40 PM

Similar Messages

  • Constructor problem with super keyword

    When I try to compile this class, I get 1 error:
    C:\Program Files\Xinox Software\JCreatorV3\MyProjects\FixedDiameterCircle.java:6: cannot resolve symbol
    symbol : constructor CircleGUI (int)
    location: class CircleGUI
    super(100);
    ^
    1 error
    class FixedDiameterCircle extends CircleGUI
         FixedDiameterCircle()
              super(100);     
         }//end FixedDiameterCircle()
    public void setDiameter(int d)
    }//end class FixedDiameterCircle
    ---------Here's the CircleGUI.java-------
    import javax.swing.*; //import Swing components
    import java.awt.*; //import awt components
    import java.awt.event.*; //import event handlers
    public class CircleGUI implements ActionListener
    JTextField diameter = new JTextField(3); //text field for first name
    JTextField color = new JTextField(5); //text field for last name
    JButton button = new JButton("Draw"); //update button
    JPanel panel = new JPanel(); //panel for frame content pane
    JFrame frame = new JFrame("Draw"); //frame for window + title
    public CircleGUI()
    panel.add(new JLabel("Diameter")); //add a label to panel
    panel.add(diameter); //add first to panel
    panel.add(new JLabel("Color")); //add another label to panel
    panel.add(color); //add a last to panel
    button.addActionListener(this); //add a click listener to button
    panel.add(button); //add button to panel
    frame.setContentPane(panel); //set panel as frame's content
    frame.setSize(120, 120); //set frame size (width, height)
    frame.setVisible(true); //make frame visible
    }//end CircleGUI()
    public void actionPerformed(ActionEvent e)//executed when button is clicked
    int d = Integer.parseInt(diameter.getText()); //get diameter
    Circle circle; //declare Circle variable
    if(color.getText().length() == 0) //if no color entered in field
    {                                       //use JColorChooser below
    Color rgb = JColorChooser.showDialog(frame, "Choose a Color", null);
    if(rgb != null) //if Color rgb chosen
    circle = new Circle(d,rgb); //instantiate Circle from Color
    }//end if(color...
    else
    String c = color.getText(); //get color String
    circle = new Circle(d,c); //instantiate Circle from String
    }//end else
    }//end actionPerformed()
    public static void main(String[] args) //main method
    CircleGUI cGUI = new CircleGUI(); //instantiate CircleGUI
    }//end main()
    }//end class CircleGUI
    What's the problem?

    CircleGUI does not have a constructor that takes an int. You need to either add this to CircleGui:public CircleGui(int diameter) { /* do stuff */ } or just cal super() instead of super(int). Which one is better is left as an exercise for the reader.

  • Public constructor problem

    I am getting the following error
    The applet orderproc.NewUser does not have a public constructor orderproc.NewUser()
    I dont understand this as the rest of my applets have similar code but dont get this problem. Can any of you nice people out there help. Here is my code:
    package orderproc;
    import java.lang.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.sql.Connection;
    import java.sql.Statement;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.ResultSet;
    import java.net.URL;
    import java.sql.*;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2003</p>
    * <p>Company: </p>
    * @author unascribed
    * @version 1.0
    public class NewUser extends JApplet implements ActionListener {
    JPanel westPanel;
    JPanel eastPanel;
    JLabel lblFirstName, lblLastName, lblPassword, lblUserName;
    JTextField txtFirstName,txtLastName,txtUserName, txtPassword;
    JButton btnSubmit, btnBack, btnCancel;
    String FN,LN,PS,UID;
    public NewUser()
    GridBagLayout gbl;
    GridBagConstraints gbc;
    gbl = new GridBagLayout();
    gbc = new GridBagConstraints();
    westPanel = new JPanel();
    westPanel.setLayout(gbl);
    eastPanel = new JPanel();
    eastPanel.setLayout(gbl);
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(westPanel, BorderLayout.CENTER);
    getContentPane().add(eastPanel, BorderLayout.SOUTH);
    lblFirstName = new JLabel("First Name: ");
    lblLastName = new JLabel("Last Name: ");
    lblPassword = new JLabel("Password: ");
    lblPassword = new JLabel("User Name: ");
    txtFirstName = new JTextField(15);
    txtPassword = new JTextField(15);
    txtLastName = new JTextField(15);
    txtUserName = new JTextField(15);
    btnSubmit = new JButton("Submit");
    btnSubmit.addActionListener(this);
    eastPanel.add(btnSubmit);
    btnCancel = new JButton("Cancel");
    btnCancel.addActionListener(this);
    eastPanel.add(btnCancel);
    btnBack = new JButton("<<<<Back");
    btnBack.addActionListener(this);
    eastPanel.add(btnBack);
    gbc.anchor = GridBagConstraints.NORTH; // Align labels
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbl.setConstraints(lblFirstName, gbc);
    westPanel.add(lblFirstName);
    gbc.gridx = 1;
    gbc.gridy = 2;
    gbl.setConstraints(lblLastName, gbc);
    westPanel.add(lblLastName);
    gbc.gridx = 1;
    gbc.gridy = 3;
    gbl.setConstraints(lblPassword, gbc);
    westPanel.add(lblPassword);
    gbc.gridx = 1;
    gbc.gridy = 4;
    gbl.setConstraints(lblUserName, gbc);
    westPanel.add(lblUserName);
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.gridx = 2;
    gbc.gridy = 1;
    gbl.setConstraints(txtFirstName, gbc);
    txtFirstName.setEditable(true);
    westPanel.add(txtFirstName);
    gbc.gridx = 2;
    gbc.gridy = 2;
    gbl.setConstraints(txtLastName, gbc);
    txtPassword.setEditable(true);
    westPanel.add(txtLastName);
    gbc.gridx = 2;
    gbc.gridy = 3;
    gbl.setConstraints(txtPassword, gbc);
    txtPassword.setEditable(true);
    westPanel.add(txtPassword);
    gbc.gridx = 2;
    gbc.gridy = 4;
    gbl.setConstraints(txtUserName, gbc);
    txtUserName.setEditable(true);
    westPanel.add(txtUserName);
    public void actionPerformed(ActionEvent ae) // Action event handling
    if(ae.getSource() == btnBack)
    setVisible(false);
    else if(ae.getSource() == btnCancel)
    txtFirstName.setText(null);
    txtPassword.setText(null);
    txtLastName.setText(null);
    txtUserName.setText(null);
    else if(ae.getSource() == btnSubmit)
    FN = txtFirstName.getText();
    LN = txtLastName.getText();
    PS = txtPassword.getText();
    UID = txtUserName.getText();
    try
    //connect to database
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    System.out.println("Drivers loaded");
    String url = "jdbc:odbc:wms";
    Connection con = DriverManager.getConnection(url,"root","");
    System.out.println("Connection established");
    Statement stmt = con.createStatement();
    System.out.println("Statement created");
    ResultSet res = stmt.executeQuery("INSERT INTO login (FirstName, LastName, Password, UserName) VALUES ('"+FN+"','"+LN+"', '"+PS+"','"+UID+"')");
    con.close();
    catch(Exception e)
    txtFirstName.setText(null);
    txtLastName.setText(null);
    txtPassword.setText(null);
    txtUserName.setText(null);
    public void init()
    NewUser myNewUser = new NewUser();

    Why don't you just implement the RSAPrivateKey and RSAPublicKey interfaces?

  • Socket constructor problems

    I have a moderate amount of experience with Java, but am new to network programming. I am using the Socket class, but the client stalls at the line containing the Socket constructor. I have been all over the web, and have checked numerous code examples, but my code seems to check out. Here is the constructor and relevant code:
    final int LOAD_PORT = 7778;
    InetAddress addr = InetAddress.getByName("127.0.0.1");
    Socket socket = new Socket(addr, LOAD_PORT);
    I am trying to just get this to work with both the client and the server running on my machine to start with. I have some TextArea.append statements interspersed so that I know which line stalls, and the last .append statement that works is just before the Socket constructor line.
    If anyone might know what my problem is, please respond.

    I tried that and about a million other combinations.
    I finally figured the problem out about a week ago...
    I needed to upgrade to SDK 1.4.0 from SDK 1.3.1. I tested this program out on a system using 1.4 and it worked fine with no modifications at all. Then I went back to a 1.3 system, it didn't work, I downloaded and installed 1.4, tried it again, and it worked like a charm.
    Thanks for the reply, though,
    Tim

  • Instantiation attempted on a non-constructor problem

    Hi,
    I've got the following error in my application: "TypeError: Error #1007: Instantiation attempted on a non-constructor".
    I've created a class that represents a 2D Vector. But when I instanciate it inside another class, I get this error.
    Here is a little piece of code of my problem:
    public class Player extends MovieClip {
              private var position:Vector = new Vector();
              public function Player() {
                        // constructor code
    public class Vector {
              public var xValue:Number;
              public var yValue:Number;
              public function Vector() {
                        // constructor code
                        xValue = 0;
                        yValue = 0;
    These 2 classes are in separated files. The Player's class is a Movie Clip in the library, while Vector's class is just a class file. What can I be doing wrong?

    Vector is a native top level class in AS3.

  • Rectangle constructor problem

    Ok, i've seen a couple posts on this in other threads, but it seemed like people were asking for you guys to complete their homework for them. This is an assignment calling for us to construct 2 rectangles, modify the second, then verify that the first remained unaltered. This is my main code here:
    public static void main(String[] args)
              // Creates object "rectangle A"
              Rectangle rectangleA = new Rectangle();
              // Tests rectangle A's components
              System.out.println("Rectangle A's componenets are as follows:");
              System.out.println("Height: " + rectangleA.getHeight());
              System.out.println("Width: " + rectangleA.getWidth());
              System.out.println("Color: " + rectangleA.getColor());
              // Creates object "rectangle B"
              Rectangle rectangleB = new Rectangle(2, 2, "Blue");
              // Tests rectangle B's components
              System.out.println('\n' + "Rectangle B's components are as follows:");
              System.out.println("Height: " + rectangleB.getHeight());
              System.out.println("Width: " + rectangleB.getWidth());
              System.out.println("Width: " + rectangleB.getColor());
              // Checks setComponent methods on rectangle B for functionality
              rectangleB.setHeight(3);
              rectangleB.setWidth(4);
              rectangleB.setColor("Azul");
              // Checks the changes to rectangle B
              System.out.println('\n' + "Rectangle B's new components are as follows:");
              System.out.println("Height: " + rectangleB.getHeight());
              System.out.println("Width: " + rectangleB.getWidth());
              System.out.println("Color: " + rectangleB.getColor());
              // Prints components of rectangle A to verify that it has remained unaltered
              System.out.println('\n' + "Rectangle A's components are still:");
              System.out.println("Height: " + rectangleA.getHeight());
              System.out.println("Width: " + rectangleA.getWidth());
              System.out.println("Color: " + rectangleA.getColor());
    }Here is the second class, including the completed (as correct as I could come haha) rectangle constructors and methods:
    public class Rectangle
         private double width = 1;
         private double height = 1;
         private static String color = "White";
         public Rectangle()
         public Rectangle(double width, double height, String color)
              this.width = width;
              this.height = height;
              this.color = color;
         public double getWidth()
              return width;
         public void setWidth(double width)
              this.width = width;
         public double getHeight()
              return height;
         public void setHeight(double height)
              this.height = height;
         public static String getColor()
              return color;
         public static void setColor(String color)
              Rectangle.color = color;
         public double findArea()
              return (this.getHeight() * this.getWidth());
    }We are supposed to use each rectangle constructor once, then use a series of print statements to check each method/constructor in the Rectangle class. I will add findArea to the main class later.
    So... my problem is that the second rectangle object's "color" property is messing with the first rectangle's color as well, when I run the program, rectangle A ends up with a color of "Azul" instead of "White."
    Any ideas?

    Ok, after reading the link, static is a class variable, meaning that it encompasses the whole class, and any alteration to it sticks. Any reference to it after that will return the new value, as it is supposed to. So, how can I temporarily change the color without reassigning it to the whole class? The instructor intentionally made it static, so I think he meant for us to try to work around that.
    Looking back at my code, I am, indeed, changing the variable itself, rather than a property of the current object. it seems to me the problem lies within this bit of code.
    public static void setColor(String color)
              Rectangle.color = color;
         }Message was edited by:
    mchenj

  • Constructor-problem

    public class Three extends Two {
         public static void main(String args[])
              new Three();
    public class Two extends One{
         public Two()
              this(5);
              System.out.println("Constructor of class Two");
         public Two(int x)
              System.out.println("Value of x is   "+x);
    public class One {
         public One()
              System.out.println("Constructor of class One");
    If we do not create any zero argument constructor then the JVM creates one for us and the calls the constructor of the superclass(if any) using super(); and if we do create a zero argument constructor and do not specify super() then it is automatically called.--Is this correct
    If so, when I run class Threethen class Two constructor should be called which calls another constructor of class Two and in this case JVM should not be able to call Parent Constructor One using super() since we have already placed this(5) in the first line of the constructor and I believe super and this cannot be used together.
    So how does constructor of class One get called.

    If we do not create any zero argument constructor
    then the JVM creates one for us and the calls the
    constructor of the superclass(if any) using super();
    and if we do create a zero argument constructor and
    do not specify super() then it is automatically
    called.--Is this correct Mostly. The compiler creates the ctor, I think, not the VM. And it only gets created if you didn't define any ctors for that class.
    Regardless of what ctors you have or have not created, super() will be implicitly called as the first statement of each ctor unless that ctor's first statemen is a call to a super() or a this() ctor (with or without args).
    and in
    this case JVM should not be able to call Parent
    Constructor One using super() since we
    have already placed this(5) in the first line
    of the constructor and I believe super and
    this cannot be used together.Incorrect.
    Three() calls Two() calls Two(5) calls One().
    Constructor rules:
    1) Every class has at least one ctor.
    1.1) If you do not define an explicit constructor for your class, the compiler provides a implicit constructor that takes no args and simply calls super().
    1.2) If you do define one or more explicit constructors, regardless of whether they take args, then the compiler no longer provides the implicit no-arg ctor. In this case, you must explicitly define a public MyClass() {...} if you want one.
    1.3) Constructors are not inherited.
    2) The first statement in the body of any ctor is either a call to a superclass ctor super(...) or a call to another ctor of this class this(...) 2.1) If you do not explicitly put a call to super(...) or this(...) as the first statement in a ctor that you define, then the compiler implicitly inserts a call to super's no-arg ctor super() as the first call. The implicitly called ctor is always super's no-arg ctor, regardless of whether the currently running ctor takes args.
    2.2) There is always exactly one call to either super(...) or this(...) in each constructor, and it is always the first call. You can't put in more than one, and if you put one in, the compiler's implicitly provided one is removed.

  • Creating a cookie, constructor problem...

    I have a servlet that creates a cookie when a user registers...
    int typeUserInt = Integer.parseInt(typeUserString);
    if(typeUserInt == 0) {     
         Cookie cookie = new Cookie("trialUser", customerid);
               cookie.setMaxAge(86400*14);
         response.addCookie(cookie);
         System.out.println("trial user cookie value is "+customerid); //error check
      }     However I am getting this error when I compile...
    cannot find symbol
    symbol: constructor Cookie(java.lang.String, int)
    location: class javax.servlet.http.Cookie
    Cookie cookie = new Cookie("trialUser", customerid);
    ^
    Any advice anyone, all my other cookies in servlets are created in the same way and they all work! Why wont this one work?

    Some basic thing like you didn't import the class or... hang on a bit, let me look at the documentation... okay, the only constructor for Cookie takes two Strings as its parameters. You aren't passing two Strings.

  • A constructor problem ,please help!

    class a
    int x;
    int y;
    a(int a,int b)
    x=a;
    y=b;
    class b extends a
    public class test
    public static void main (String args[])
    a test=new a(1,2);
    System.out.println(test.x);
    System.out.println(test.y);
    cannot resolve symbol
    symbol : constructor a ()
    location: class a
    class b extends a
    ^
    1 error

    You don't declare any constructor in class b, therefor the compiler will add the no-arg constructor to it, which will try to call a no-arg constructor in class a:
    class b extends a {
    public b() {
      super();
    }But notice, that you have a constructor in a that takes two int arguments, so in class b, you have to make a constructor which will call super(i1, i2), where i1 and i2 are integers.
    How come you extend class a anyway? The example you gave, indicates you don't need to extend class a in b.

  • About Constructor problem

    Could anyone tell me why the contructor will be called twice times when I run the following code.
    But if I remove the public access modifer from constructor B() then it calls only once.
    Thank you in advance !!
    // A.java
    public class A {
    A() {
    System.out.println("aa");
    // B.java
    public class B extends A {
    public B() {                        // if I change it to "B() {", then it just be called once.
    System.out.println("bb");
    public static void main(String[] args) {
    new B();
    The result shows with public modifer before B() constructor is:
    aa
    bb
    aa
    bb
    without public:
    aa
    bb

    Check whta you have done. In both codes, as must be, the constructur only is called one time, the second print is the only one which appers in my console.
    Abraham.

  • Default Constructor Problem

    i am working on a script that will create a square. i have the script working, but it only works when an int is passed in when calling the methods in main. is there a way to make the program construct a square without having to specify the int? here is the code:
    public class Square{
         public Square() {
    public static void getName(){
         System.out.println("This shape is a square");
    public void area(int x){
         double product = x * x;
         System.out.println("The area is " + product);
    public void perim(int x){
         int perim = x * 2;
         System.out.println("The perimeter is " + perim);
    public static void main(String[] args){
         Square mySquare = new Square();
         mySquare.getName();
         mySquare.area(5);
         mySquare.perim(5);
    }

    Let the class keep a record of its own dimensions by using a variable, and initialize the variable in the constructor:public class Square{
    //Here is the square's dimension:
    private int sideLength;
    public Square() {
         sideLength=5;   //this is the default length if not specified by user
    public Square(int arg) {
        sideLength=arg;
    public static void getName(){
    System.out.println("This shape is a square");
    public double area(){
    double product = sideLength * sideLength;
    System.out.println("The area is " + product);
    return product;
    public int perim(){
    int perim = sideLength * 4;
    //NOT sideLength * 2 !!
    System.out.println("The perimeter is " + perim);
    return perim;
    //good idea to have these too:
    public void setSideLength(int arg){
    sideLength = arg;
    public int getSideLength(){
    return sideLength;
    public static void main(String[] args){
    Square mySquare = new Square(10);
    //or could just use:
    //Square mySquare = new Square();
    //to get default size (5 x 5)
    //or could even get size from args[]
    mySquare.getName();
    mySquare.area();
    mySquare.perim();
    }

  • Generics with wildcard in constructor problem

    Hi All
    I have the following code
    import java.util.* ;
    public class MyClass
       public static void main(String[] argvs)
           List<?> li = new ArrayList<MyClass>();
           li.add(new MyClass()) ;
    }I get a compile error on li.add(...) which doesn't make much sense to me, any suggestions ?
    (I can fix this by replacing the wildcard with MyClass)
    Thnx
    LuCa

    List<?> effectively means "A list containing a specific, but unknown subtype of Object". This is two-fold. It ensures that everything you get out from it is at least Object (this one is easy ;-)) and it ensures that everything that gets put in is of that specific, but unknown subtype. Since the compiler can't know if any given object is of this subtype (since it's unknown) it can't allow any object into the List.

  • BigDecimal constructor problem

    BigDecimal( 2048.952375 ) gives 2048.9523749999998472048901021480560302734375. Is there any way to make it give 2048.952375. I would like to construct the BigDecimal from a double value (not a string).

    floating-point numbers are not precise in the way you expect them to behave. To format them / output them as strings, use http://java.sun.com/j2se/1.4/docs/api/java/text/DecimalFormat.html

  • Again on "call to this must be first statement in constructor"

    Hi, I've spent the last hour reading tons of docs & threads about the "call to this must be first statement in constructor" problem, but I still cannot work it out.
    Here is the code
         public Orologio(String s)
              StringTokenizer exploder=new StringTokenizer(s,":",false);
              this(Integer.parseInt(exploder.nextToken()),Integer.parseInt(exploder.nextToken()));
              }Well, I know this..() must be the first line in the method, but I need to parse my input string before passing the parameters to the Orologio(int,int) constructor!
    Thankyou!

    You could define an initialization method:private void init(int a, int b) {
        ... your initialization code that was in your constructor...
    public Orologio(String s) {
        StringTokenizer exploder=new StringTokenizer(s,":",false);
        init(Integer.parseInt(exploder.nextToken()),Integer.parseInt(exploder.nextToken()));
    public Orlogio(int a, int b) {
        init(a, b);
    }However, make sure it is the responsability of this class to handle String as constructor parameter. Maybe you should force the client to tokenize the string and provide integer values to the constructor (and then get rid of the Orologio(String s) constructor.)

  • Constructor question - dealing with protected methods

    Hi all, I'm trying to run a protected method, got somewhere by making the class a subclass - but not too sure about where to put the constructor for a class I'm trying to use (IQRegister). Can anyone help and point me in the right direction as to what I did wrong?
    public class Registration extends IQRegister {
    //Create new instance of ConnectionBean
    ConnectionBean conBean = new ConnectionBean();
    InfoQueryBuilder iqb = new InfoQueryBuilder();
    InfoQuery iq;
    //IQRegisterBuilder iqRegb = new IQRegisterBuilder();
    public Registration( IQRegisterBuilder iqRegb ) {
    super( iqRegb );
    //This constructor needs to go somewhere that will work>>>>>>>>>>>>>>
    IQRegister iqReg = new IQRegister( iqRegb );
    public void regUser() {
    String server = JOptionPane.showInputDialog( "Enter Server address" );
    InetAddress inetaddress;
    try {
    conBean.connect( inetaddress = InetAddress.getByName( server ));
    catch( UnknownHostException unknownhostexception ) {
    Object aobj[] = {
    "Cancel", "OK"
    int i = JOptionPane.showOptionDialog(null, "Retry Server?", server +
    ": Not Responding", -1, 2, null, aobj, aobj[1]);
    if( i == 1 )
    regUser();
    System.out.println( "Cannot resolve " + server + ":" + unknownhostexception.toString ());
    return;
    catch( IOException ioexception ) {
    Object aobj1[] = {
    "Cancel", "OK"
    int j = JOptionPane.showOptionDialog( null, "Cannot Connect to:",
    server,-1, 2, null, aobj1, aobj1[1] );
    if( j == 1 )
    regUser();
    System.out.println( "Cannot connect " + server);
    return;
    System.out.println( "Registering User" );
    registrationProcess();
    public void registrationProcess () {
    try {
    //Need to getXMLNS packet method getXMLNS() is protected
    iqReg.getXMLNS();
    catch ( InstantiationException e ) {
    System.out.println( "Error in building Registration packet" );
    String username = JOptionPane.showInputDialog( "Enter: Username" );
    String password = JOptionPane.showInputDialog( "Enter: Password" );
    ERROR:
    Registration.java:108: cannot resolve symbol
    symbol : variable iqReg
    location: class Registration
    iqReg.getXMLNS();
    ^
    1 error
    Thanks again :)

    Made some changes to code but getting some varied error here:
    Registration.java:31: <identifier> expected
    iqReg = new IQRegister( iqRegb );
    ^
    Registration.java:31: cannot resolve symbol
    symbol : class iqReg
    location: class Registration
    iqReg = new IQRegister( iqRegb );
    ^
    Registration.java:104: cannot resolve symbol
    symbol : variable iqReg
    location: class Registration
    iqReg.getXMLNS();
    ^
    3 errors
    CODE:
    public class Registration extends IQRegister {
    //Create new instance of ConnectionBean
    ConnectionBean conBean = new ConnectionBean();
    InfoQueryBuilder iqb = new InfoQueryBuilder();
    InfoQuery iq;
    //IQRegisterBuilder iqRegb = new IQRegisterBuilder();
    //This constructor problem here>>>>>>>>>>>>
    iqReg = new IQRegister( iqRegb );
    public Registration( IQRegisterBuilder iqRegb ) {
    super( iqRegb );
    .......same code..... as above....
    Thank you so much for the guidance..

Maybe you are looking for

  • Oracle VPD on Remote database using DBLINk

    Hi All, How can i apply row level security on a table that is available in another database using DBlink we have two databases PDSSM and EVTA, and i would like to apply row level security on a table in EVTA from a schema in PDSSM using dblink. MXODSA

  • How can I re-set new tab homepages? A website has made itself appear every time I open a new tab.

    My new tabs keep startying up with imesh, a website I don't want and haven't made a homepage. Firefox options don't show this is in your tab start-up system. How can I get rid of it?

  • How can I write an instance of a class in a static variable

    Hi ! I have an instance of a class Devisen dev = new Devisen(); In an other class I have a static method and I need there the content of some variables from dev. public static void abc() { String text=dev.textfield.getText() I get the errormessage, t

  • Error while trying to synchronise audio & midi, Motu 828 mkII

    Hi, I've tried lots of things before posting this but am running out of ideas - any help appreciated. Since upgrading from Tiger to Snow Leopard, my MOTU 828mkII has not been working right. The problem happens in Logic 8 and all other apps I've tried

  • Installation error for NW CE 7.2 Trial

    Hello Experts- When I started SAPinst file for installation. After couple of minutes on I see see the installation is aborted with the following error Connection to SAPinst refused with the following message connection to SAPinst could not be establi