Help with a method

The following method is supposed to Return an array of integers representing all of the unoccupied rooms which has the required number of double and single beds. The length of the resulting array is the same as the number of matching rooms (which may be 0 if there are no rooms of the required size available).
The following outline was given to me to complete allong with a few comments from my tutor.
    public int[] getEmptyRooms (int doubleBeds, int singleBeds) {
        // Return an array of integers representing all of the unoccupied rooms
        // which has the required number of double and single beds. The length of
        // the resulting array is the same as the number of matching rooms
        // (which may be 0 if there are no rooms of the required size available).
        // At the very least you need to change the following statement
        // ge - don't change this statemnt
        int numEmpty = 0;
         * ge
         * yu have still to attempt this
         * you need to use a loop to go through all the rooms and see if
         * they are not occupied and have the required no of double and single beds
         * then increase numEmpty by 1
        // At the very least you need to change the following statement
        //ge - this statement looks ok
        int[] rooms = new int[numEmpty];
         * however, you will now nee to loop through all the rooms
         * and if it meets the same test as previously
         * then add i to the rooms array
        // At the very least you need to change the following statement 
        return rooms;
    }I have done the following but to say the least it deosnt return what is required.
public int[] getEmptyRooms (int doubleBeds, int singleBeds) {
        // Return an array of integers representing all of the unoccupied rooms
        // which has the required number of double and single beds. The length of
        // the resulting array is the same as the number of matching rooms
        // (which may be 0 if there are no rooms of the required size available).
        int numEmpty = 0;
        for(int i = 0; i < theRooms.length; i++)
            if(!theRooms.isOccupied() && theRooms[i].hasRequiredBeds(doubleBeds, singleBeds))
numEmpty++;
int[] rooms = new int[numEmpty];
for(int i = 0; i < theRooms.length; i++)
if(!theRooms[i].isOccupied() && theRooms[i].hasRequiredBeds(doubleBeds, singleBeds))
i++
return rooms;
I really need to get this sorted out soon as i need to submit it tomorrow and i cant seem to see what is wrong (partially because im not great at java).
So any help what so ever will be greatly appreciated

The following is returned when i try and run the hotel appilcation
[l@e33af5
and that is when the following code is used
    public int[] getEmptyRooms (int doubleBeds, int singleBeds) {
        // Return an array of integers representing all of the unoccupied rooms
        // which has the required number of double and single beds. The length of
        // the resulting array is the same as the number of matching rooms
        // (which may be 0 if there are no rooms of the required size available).
        int numEmpty = 0;
        for(int i = 0; i < theRooms.length; i++)
            if(!theRooms.isOccupied() && theRooms[i].hasRequiredBeds(doubleBeds, singleBeds))
numEmpty++;
int[] rooms = new int[numEmpty];
int x = 0;
for(int i = 0; i < theRooms.length; i++)
if(!theRooms[i].isOccupied() && theRooms[i].hasRequiredBeds(doubleBeds, singleBeds))
rooms[x] = 0;
x++;
return rooms;

Similar Messages

  • Need help with Sound Methods

    Hi, I am new to java and need help with sound methods.
    q: create a new method that will halve the volume of the positive values and double the volume of the negative values.
    Message was edited by:
    Apaula30

    duplicate message #2

  • Help with findByDateRange method in CMP enity bean

    Hello,
    I am trying to deploy my entity beans to WebLogic 7, runnning on a Sun Solaris
    box. The application connects to an Oracle 9i database. I am having problems with
    2 queries in my ejb-jar.xml file which correspond to 2 finder methods. These finder
    methods take two java.util.Date parameters. I have read that EJB QL does not support
    dates or date literals in its WHERE clause and one has to use long values of these
    dates. I tried various combinations but haven't been able get the query to work.
    Here is an excerpt from my ejb-jar.xml file
    <query>
    <query-method>
    <method-name>findBySalesOrderID</method-name>
    <method-params>
    <method-param>java.lang.Long</method-param>
    </method-params>
    </query-method>
    <ejb-ql>
    SELECT OBJECT(c) FROM Equipment c
    WHERE c.salesOrderID = ?1
    </ejb-ql>
    </query>
    <query>
    <query-method>
    <method-name>findEquipmentByStagingDateRange</method-name>
    <method-params>
    <method-param>java.util.Date</method-param>
    <method-param>java.util.Date</method-param>
    </method-params>
    </query-method>
    <ejb-ql>
    <![CDATA[
    SELECT OBJECT(c) FROM Equipment c
    WHERE c.equipReqStageDate >= ?1 AND c.equipReqStageDate <= ?2
    ]]>
    </ejb-ql>
    </query>
    <query>
    <query-method>
    <method-params>
    <method-param>java.util.Date</method-param>
    <method-param>java.util.Date</method-param>
    </method-params>
    </query-method>
    <ejb-ql>
    <![CDATA[
    SELECT OBJECT(c) FROM Equipment c
    WHERE c.equipReqShipDate >= ?1 AND c.equipReqShipDate <= ?2
    ]]>
    </ejb-ql>
    </query>
    Do I have to change the method parameters to java.lana.Long or to 'long' literal
    from java.util.Date?
    Here is the finder method signature in the home interface
    public java.util.Collection findEquipmentByStagingDateRange(java.util.Date begDate,
    java.util.Date engDate) throws javax.ejb.FinderException, java.rmi.RemoteException;
    public java.util.Collection findEquipmentByShippingDateRange(java.util.Date begDate,
    java.util.Date engDate) throws javax.ejb.FinderException, java.rmi.RemoteException;
    Do I have to pass in Dates or java.lang.Longs or 'long' literals?
    Any help is really appreciated. Thanks.
    [question.txt]

    Did you try java.sql.Date?
    /k
    "John Carson" <[email protected]> wrote in message
    news:[email protected]...
    >
    Hello,
    I am trying to deploy my entity beans to WebLogic 7, runnning on a SunSolaris
    box. The application connects to an Oracle 9i database. I am havingproblems with
    2 queries in my ejb-jar.xml file which correspond to 2 finder methods.These finder
    methods take two java.util.Date parameters. I have read that EJB QL doesnot support
    dates or date literals in its WHERE clause and one has to use long valuesof these
    dates. I tried various combinations but haven't been able get the query towork.
    Here is an excerpt from my ejb-jar.xml file
    <query>
    <query-method>
    <method-name>findBySalesOrderID</method-name>
    <method-params>
    <method-param>java.lang.Long</method-param>
    </method-params>
    </query-method>
    <ejb-ql>
    SELECT OBJECT(c) FROM Equipment c
    WHERE c.salesOrderID = ?1
    </ejb-ql>
    </query>
    <query>
    <query-method>
    <method-name>findEquipmentByStagingDateRange</method-name>
    <method-params>
    <method-param>java.util.Date</method-param>
    <method-param>java.util.Date</method-param>
    </method-params>
    </query-method>
    <ejb-ql>
    <![CDATA[
    SELECT OBJECT(c) FROM Equipment c
    WHERE c.equipReqStageDate >= ?1 AND c.equipReqStageDate <= ?2
    ]]>
    </ejb-ql>
    </query>
    <query>
    <query-method>
    <method-params>
    <method-param>java.util.Date</method-param>
    <method-param>java.util.Date</method-param>
    </method-params>
    </query-method>
    <ejb-ql>
    <![CDATA[
    SELECT OBJECT(c) FROM Equipment c
    WHERE c.equipReqShipDate >= ?1 AND c.equipReqShipDate <= ?2
    ]]>
    </ejb-ql>
    </query>
    Do I have to change the method parameters to java.lana.Long or to 'long'literal
    from java.util.Date?
    Here is the finder method signature in the home interface
    public java.util.Collection findEquipmentByStagingDateRange(java.util.DatebegDate,
    java.util.Date engDate) throws javax.ejb.FinderException,java.rmi.RemoteException;
    >
    public java.util.CollectionfindEquipmentByShippingDateRange(java.util.Date begDate,
    java.util.Date engDate) throws javax.ejb.FinderException,java.rmi.RemoteException;
    >
    Do I have to pass in Dates or java.lang.Longs or 'long' literals?
    Any help is really appreciated. Thanks.

  • Help with payment methods

    When I go to log into my account, or download an app it says I need to log in and update my payment method. I log back in, and go to input my credit card details. It says that this method is invalid, please choose a different one. I then go to input a different credit cards details, and it still says its invalid. It even won't let me delete these details as the credit card type does not match the credit card information. I then thought to make a new account, and seeing you have to provide a billing method I used the same credit card that failed the first time with my other account. It then says that you need to contact ITunes support to validate this account and it won't let me.
    With the first account it wont let me do anything! Download apps, purchase them, or even update them! Please help!

    Are you aware of any problem with a previous purchase ? If not then you can try contacting iTunes Support via this link and see if they can help : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption
    What payment method do you currently have on your account, and have you been into your account and checked the details ? If it's a debit card then I don't think that they are still accepted as a valid payment method - they are not listed on this page and there have been a number of posts recently about them being declined
    If it's a credit card then is it registered to exactly the same name and address (including format and spacing etc) that you have on your iTunes account, it was issued by a bank in your country and you are currently in that country ?

  • Help with static method issue.

    Hi everyone,
    There's a recent thread on the forum along a similar vein as this one but I hope mine doesn't cause as much annoyance! My homework assignment involves implementing three interfaces provided by my professor in order to create weighted, undirected graphs. The classes I have to implement are Node, Edge and Graph. Here are the Edge and Node interfaces for reference; they weren't too hard to implement:
    public interface Edge {
         public Edge createEdge(String name, int ID, float weight);
         public Node getStartNode();
         public void setStartNode(Node n);
         public Node getEndNode();
         public void setEndNode(Node n);
         public String getName();
         public int getID();
         public float getWeight();
         public String toString();
    public interface Node {
         public Node createNode(String name, int ID, float weight);
         public Node[] getNeighbours();
         public Edge[] getEdges();
         public void addEdge(Edge e);
         public void removeEdge(Edge e);
         public String getName();
         public int getID();
         public float getWeight();
         public String toString();
    }Now, one of the graphs I should be aiming to create is this one ( [http://i35.tinypic.com/2iqn62d.gif|http://i35.tinypic.com/2iqn62d.gif] ) so I apologize for the code I'm about to show and its length. It's the Graph class:
    import java.util.ArrayList;
    public class Graph {
         public static void main(String [] args) {
              // Create all nodes
              int i = 1;
              Node food = new Node();
              food.createNode("Food", i, 0);
              i++;
              Node healthy = new Node();
              healthy.createNode("Healthy", i, 4f);
              i++;
              Node neutral = new Node();
              neutral.createNode("Neutral", i, 0);
              i++;
              Node unhealthy = new Node();
              unhealthy.createNode("Unhealthy", i, -4f);
              i++;
              Node orange = new Node();
              orange.createNode("Orange", i, 6f);
              i++;
              Node cabbage = new Node();
              unhealthy.createNode("Cabbage", i, 3f);
              i++;
              Node riceCake = new Node();
              unhealthy.createNode("Rice cake", i, 2f);
              i++;
              Node chocolate = new Node();
              unhealthy.createNode("Chocolate", i, -2f);
              i++;
              Node bacon = new Node();
              unhealthy.createNode("Bacon", i, -4f);
              i++;
              Node xmasPud = new Node();
              unhealthy.createNode("Christmas Pudding", i, -8f);
              i++;
              // Create all edges
              int n = 1;
              Edge food1 = new Edge();
              food1.createEdge("to healthy", i, -4.0f);
              food1.setStartNode(food);
              food1.setEndNode(healthy);
              n++;
              Edge food2 = new Edge();
              food2.createEdge("to neutral", i, 0);
              food2.setStartNode(food);
              food2.setEndNode(neutral);
              n++;
              Edge food3 = new Edge();
              food3.createEdge("to unhealthy", i, -4f);
              food3.setStartNode(food);
              food3.setEndNode(unhealthy);
              n++;
              Edge healthy1 = new Edge();
              healthy1.createEdge("to orange", i, 4f);
              healthy1.setStartNode(healthy);
              healthy1.setEndNode(orange);
              n++;
              Edge healthy2 = new Edge();
              healthy2.createEdge("to cabbage", i, 2f);
              healthy2.setStartNode(healthy);
              healthy2.setEndNode(cabbage);
              n++;
              Edge neutral1 = new Edge();
              neutral1.createEdge("to rice cake", i, 2f);
              neutral1.setStartNode(neutral);
              neutral1.setEndNode(riceCake);
              n++;
              Edge unhealthy1 = new Edge();
              unhealthy1.createEdge("to chocolate", i, -2f);
              unhealthy1.setStartNode(unhealthy);
              unhealthy1.setEndNode(chocolate);
              n++;
              Edge unhealthy2 = new Edge();
              unhealthy2.createEdge("to bacon", i, -4f);
              unhealthy2.setStartNode(unhealthy);
              unhealthy2.setEndNode(bacon);
              n++;
              Edge unhealthy3 = new Edge();
              unhealthy3.createEdge("to Christmas pudding", i, -8f);
              unhealthy3.setStartNode(unhealthy);
              unhealthy3.setEndNode(xmasPud);
              n++;
              // Assign edges to edgeList
              food.edgeList.add(food1);
              food.edgeList.add(food2);
              food.edgeList.add(food3);
              // Add node to nodeList
              nodeList.add(food);
              healthy.edgeList.add(healthy1);
              healthy.edgeList.add(healthy2);
              nodeList.add(healthy);
              neutral.edgeList.add(neutral1);
              nodeList.add(neutral);
              unhealthy.edgeList.add(unhealthy1);
              unhealthy.edgeList.add(unhealthy2);
              unhealthy.edgeList.add(unhealthy3);
              nodeList.add(unhealthy);
              // Now convert to arrays
              Node[] nodeArray = new Node; // Nodes
              nodeList.toArray(nodeArray);
              Edge[] edgeArray = new Edge[n]; // Edges
              food.edgeList.toArray(edgeArray);
              healthy.edgeList.toArray(edgeArray);
              unhealthy.edgeList.toArray(edgeArray);
              // Now turn it all into a graph
              createGraph("Food", 1, nodeArray, edgeArray, food); // doesn't work!
         public Graph createGraph(String name, int ID, Node[] nodes, Edge[] edges,
                   Node root) {
              graphName = name;
              graphID = ID;
              graphNodes = nodes;
              graphEdges = edges;
              graphRoot = root;
              return null;
         public String getName() {
              return graphName;
         public Edge[] getEdges() {
              return graphEdges;
         public void addEdge(Edge e) {
         public Edge getEdge(String name, int ID) {
              return null;
         public void removeEdge(Edge e) {
         public Node[] getNodes() {
              return graphNodes;
         public void addNode(Node n) {
              nodeList.add(n);
         public Node getNode(String name, int ID) {
              int ni = nodeList.indexOf(name);
              Node rNode = nodeList.get(ni);
              return rNode;
         public void removeNode(Node n) {
              nodeList.remove(n);
         public void setRoot(Node n) {
              graphRoot = n;
         public Node getRoot() {
              return graphRoot;
         private String graphName;
         private int graphID;
         private Node[] graphNodes;
         private Edge[] graphEdges;
         private Node graphRoot;
         private static ArrayList<Node> nodeList = new ArrayList<Node>();
    }The problem I have is that I don't know how to get around the fact that I'm making a static reference to the non-static method *createGraph*. I'd really appreciate your help. Thanks for your time!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    GiselleT wrote:
    public interface Edge {
         public Edge createEdge(String name, int ID, float weight);
    I want to kick your professor right in the grapes for this bit of idiocy. It's at the source of your problems.
    This looks very fishy and very bad. I wouldn't expect an Edge to create another Edge. Likewise for Node and Graph. You might have static factory methods in these classes, but by defining it in the interfaces, these methods have to be non-static. This leads to such ridiculous code as you have like this:
    Edge uselessEdge = new Edge();
    Edge actualEdge = uselessEdge.createEdge("abc", 1, 2.34);It's not your fault that it's useless. That's the way you have to do it with that senseless requirement.
    The problem I have is that I don't know how to get around the fact that I'm making a static reference to the non-static method createGraph.
    Static reference in non-static context errors are always addressed the same way: Either make the member in question static (usually the wrong choice) or create an instance.
    In this case, you need to do like you did with Edge, and create a useless dummy Graph whose only purpose is to create other Graphs:
    Graph graph = uselessGraph();
    Graph actualGraph = uselessGraph.createGraph(...);Then, inside the createGraph method, you'll create a Graph with new and do thatGraph.name = name; and so on for each of the parameters/members.
    Really, though, this is just an awful, awful approach though. Are you sure your prof really requires Edge to have a non-static createEdge method, and so on?

  • Please help with this method

    im creating a little animation of pacman, just an animation of it moving buy its self. im using the java elements package so this is all being shown in a drawing window.
    ive made it move fine and go round the window abit eating dots but the code is a mess, and i know i could change some of the main part into a few simple methods and have tried but it seems to stop moving when i try
    below is part of the code, the first three blocks are when its moving sideways with its mouth in three different states, and the bottom three blocks are it moving down with its mouth in three states again.
    Arc pacarc = new Arc();
    while (startmv++<stopmv)
    pac1x += 4;
    d.setForeground(Color.yellow);
    pacarc = new Arc(pac1x,pac1y,pacsize1,pacsize2,pacmouth1,pacangle1);
    d.fill(pacarc);
    d.setForeground(Color.black);
    waitNSeconds(1);
    d.fill(pacarc);
    pac1x += 4;
    d.setForeground(Color.yellow);
    pacarc = new Arc(pac1x,pac1y,pacsize1,pacsize2,pacmouth2,pacangle2);
    d.fill(pacarc);
    d.setForeground(Color.black);
    waitNSeconds(1);
    d.fill(pacarc);
    pac1x += 4;
    d.setForeground(Color.yellow);
    pacarc = new Arc(pac1x,pac1y,pacsize1,pacsize2,pacmouth3,pacangle3);
    d.fill(pacarc);
    d.setForeground(Color.black);
    waitNSeconds(1);
    d.fill(pacarc);
    while (startdwn++<stopdwn)
    pac1y +=4;
    d.setForeground(Color.yellow);
    pacarc = new Arc(pac1x,pac1y,50,50,pacdwn1,pacdwnang1);
    d.fill(pacarc);
    d.setForeground(Color.black);
    waitNSeconds(1);
    d.fill(pacarc);
    pac1y +=4;
    d.setForeground(Color.yellow);
    pacarc = new Arc(pac1x,pac1y,50,50,pacdwn2,pacdwnang2);
    d.fill(pacarc);
    d.setForeground(Color.black);
    waitNSeconds(1);
    d.fill(pacarc);
    pac1y +=4;
    d.setForeground(Color.yellow);
    pacarc = new Arc(pac1x,pac1y,50,50,pacdwn3,pacdwnang3);
    d.fill(pacarc);
    d.setForeground(Color.black);
    waitNSeconds(1);
    d.fill(pacarc);
    so for the first part i tried putting this into a method and running the program but where i had used the method the pacman shape just stayed still. any help please guys?
    this is the code for the method i tried (this is just for thefirst state of the pacmans mouth while moving sideways)
    public static void pacmve(int pactestx, int pactesty, int pacsizetest1, int pacsizetest2, int pacmouthtest, int pacangletest)
    pactestx += 4;
    Arc pacarc = new Arc();
    d.setForeground(Color.yellow);
    pacarc = new Arc(pactestx,pactesty,pacsizetest1,pacsizetest2,pacmouthtest,pacangletest);
    d.fill(pacarc);
    d.setForeground(Color.black);
    waitNSeconds(1);
    d.fill(pacarc);
    this is the loop i where i was trying to use the method
    while (startmv++<stopmv)
    pacmve(20,20,50,50,45,270);
    Edited by: jeffsimmo85 on Nov 22, 2007 1:18 AM

    When you post a code on a public forum, the code must be:
    1)Properly formatted using code tags.
    2)Generally compilable and runnable for us casual forum viewers.
    3)Reproducible of your problems when we run it.

  • Help with the method copyPixels

    Hello good day!
    I need a force in  a scheme that I am doing with a combobox that I created to select a  font of a text. I would like to display the text to the source, but do  not want to imply load all sources that I am offering 30, then a  solution that I thought it would be feasible to use an image with these  sources, then in that case all that needs to be done would be to carry this image that has about 30kb which would be a process not so  slow.
    For this did the following: I created the image in my library  as a movie clip and then used two BitmapData and a bitmap to display the  image as follows:
        var bmp: Bitmap;
        / / Lista_fonte  is my image of the sources
        var list: = new  lista_fonte lista_fonte ();
        / / Create a  BitmapData from the list instantiated
        var bmd:  BitmapData = new BitmapData (lista.width, lista.height, true);
        / / Create a BitmapData less for the item from combobox
        var bmdtemp:  BitmapData = new BitmapData (lista.width, 20, true);
    And then I go  with a paragraph of the sources and use the copyPixels to copy part of  the image:
        for (var i: int = 0; i <30; i) (
            bmdtemp.copyPixels (bmd, new Rectangle (0,0, lista.width, 20),  new Point (0, 20 * i));
            bmp = new  Bitmap (bmdtemp);
            addChild (bmp);
    Above would look like this,  but I have two problems:
    1 The picture is transparent with the  background and create the BitmapData I allow there is an overhead  transparency, but the picture shows a white background!
    2 are just  copying the image at position 0.0 in the case is with any combo of the  first source image only.
    I hope that was clear, please help me now  to break the head at a time on it and I read in some forums and some  discusões around and nothing.

    wannabehacker wrote:
    But my actual question remained unanswered. Would you please take a look at the method if you have some time and explain to me how the method is converting the IP to decimal.
    public class CharTest {
        public static void main(String[] args) {
            int b = '0';
            System.out.println(b);
    }This prints out 48. What do you think the significance of that is, and what do you think would happen if I did
    int c = '8' - '0';
    System.out.println(c);

  • Help with itemStateChanged method

    I have created an applet which diplays a combobox,three buton being play, stop and loop. The program runs but only plays the first two sound files and not the rest. I thin it has something to do with my itemStateChanged() method.
    Any help id be very grateful......
    Heres the programme
    // Java Core Packages
    import java.applet.Applet;
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    //Java extension packages
    import javax.swing.*;
    * Loads and Plays audio clips with
    * the addition of a loop function
    * @author L_Tambiah
    * @version 01
    public class LoadAudioAndPlay extends JApplet
    private AudioClip sound1, sound2, sound3, sound4, sound5, sound6, currentSound;
    private JButton playSound, loopSound, stopSound;
    private JComboBox chooseSound;
    //load the image when the applet begins executing
    public void init()
    Container container = getContentPane();
    container.setLayout( new FlowLayout() );
    String choices[] = { "Bottle", "Flute", "Space music", "Trippy",
    "dandb", "garage"};
    chooseSound = new JComboBox( choices );
    chooseSound.addItemListener(
    new ItemListener()
    //stop sound and change to sound to users selection
    public void itemStateChanged( ItemEvent e )
    currentSound.stop();
    currentSound = chooseSound.getSelectedIndex() == 0 ?
    sound1 : sound5;
    }// end anonymous inner class
    );// end addItemListener method call
    container.add( chooseSound );
    //set up button event handler and buttons
    ButtonHandler handler = new ButtonHandler();
    playSound = new JButton( "Play" );
    playSound.addActionListener( handler );
    container.add( playSound );
    loopSound = new JButton( "Loop" );
    loopSound.addActionListener( handler );
    container.add( loopSound );
    stopSound = new JButton( "Stop" );
    stopSound.addActionListener( handler );
    container.add( stopSound );
    //load sounds and set currentSound
    sound1 = getAudioClip( getDocumentBase(), "bottle.wav" );
    sound2 = getAudioClip( getDocumentBase(), "flute.aif" );
    sound3 = getAudioClip( getDocumentBase(), "spacemusic.au" );
    sound4 = getAudioClip( getDocumentBase(), "trippy.mid" );
    sound5 = getAudioClip( getDocumentBase(), "dandb.wav" );
    sound6 = getAudioClip( getDocumentBase(), "garage.wav" );
    currentSound = sound1;
    } //end method init
    //stop the sound when the user switches web pages
    public void stop()
    currentSound.stop();
    //private inner class to handle button events
    private class ButtonHandler implements ActionListener {
    //process play, loop and stop button events
    public void actionPerformed( ActionEvent actionEvent )
    if ( actionEvent.getSource() == playSound )
    currentSound.play();
    else if ( actionEvent.getSource() == loopSound )
    currentSound.loop();
    else if ( actionEvent.getSource() == stopSound )
    currentSound.stop();
    L.Tambiah
    E0261830

      AudioClip[] clips = {
        sound1, sound2, sound3, sound4, sound5, sound6
      public void itemStateChanged(ItemEvent e) {
        if(e.getStateChange() == ItemEvent.SELECTED) {
          currentSound.stop();
          currentSound = clips[chooseSound.getSelectedIndex()];
      } For more information:
    http://java.sun.com/docs/books/tutorial/uiswing/events/itemlistener.html

  • Help with a method for battleships

    Hi, I am doing a battleships applet, so far things are going well, except for the fact that I am using two methods of input for my ships, the first one is manual input, the user types in the textfields to place the ship, the second one is by using random number generators to place the ship and define if they are to be place horizontally and vertically. Here is my method for the PC placement. My question is how to write a method, which doesn`t allow the ships to overlap in any way?
    {int a = (int) (Math.random()*2);
                   rowindex[0] = 1 + (int) (Math.random() * 11);
                   colindex[0] = 1 + (int) (Math.random() * 11);
                   showship[1] = true;
                   if(a==1){
                   orientation[1] = true;
                   for(int i = 0;i<bsholder.length;i++){
                   bsholder[i] = (colindex[0]+i);
                   System.out.println(bsholder);
                   System.out.println();
                   else {
                   orientation[1] = false;
                   for (int i=0; i<bsholder.length;i++){
                   bsholder[i] = (rowindex[0]+i);
                   System.out.println(bsholder[i]);
              System.out.println();
                   int b = (int) (Math.random()*2);
                   rowindex[1] = 1 + (int) (Math.random() * 12);
                   colindex[1] = 1 + (int) (Math.random() * 12);
                   showship[2] = true;
                   if (b==1){
                   orientation[2] = false;
                   for (int i=0; i<cruisholder.length;i++){
                   cruisholder[i] = (rowindex[1]+i);
                   System.out.println(cruisholder[i]);
                   System.out.println();
                   else {
                   orientation[2] = true;
                   for (int i=0; i<cruisholder.length;i++){
                   cruisholder[i] = (colindex[1]+i);
                   System.out.println(cruisholder[i]);
                   System.out.println();
                   int c = (int) (Math.random()*2);
                   rowindex[2] = 1 + (int) (Math.random() * 13);
                   colindex[2] = 1 + (int) (Math.random() * 13);
                   showship[3] = true;
                   if (c==1)orientation[3] = true;
                   else orientation[3] = false;
                   rowindex[3] = 1 + (int) (Math.random() * 14);
                   colindex[3] = 1 + (int) (Math.random() * 14);
                   showship[4] = true;
    rowindex and colindex are the arrays I use for the graphical representation of the ships on the board. orientation is a boolean array used to define the horizontal or vertical placement. bsholder and cruisholder are arrays to store the coordinates of the ships. I am currently not using one for 2square ship and 1square ship because this is just a test programm.I am using the System.out.println is not going to be included in the end version. Please help me, I ve been stuck on it for days. I have tried all sorts of for loops includen the "enchanced for" loop but still no luck. Many thanks in advance.

    mpenoushliev wrote:
    Wow, thanks a lot I will try it out, only one last question, should the holder for the ship (the array that has the location of the ship be a 2D array or could I use a standard array and combine that with either the row or col to track the ship. (That is what I am doing now). Once again thank you very much for the help.I wrote a battleship game a few weeks ago for fun, and I created a Board class that has a 2D array of Cells. The Cell class holds a reference to 1 ShipElement, which is a single piece of a whole Ship. The Ship class has a List of ShipElements, and is used to keep track of when whole ships are sunk, etc. The Board class is responsible for placing ships, and it iterates over the Cells. The Cell class has methods that tell you if it has a ShipElement or just Water, and you can use the size of the Board to check you haven't gone over the edge. Hope it helps!

  • Help with some methods !! Please..

    Hi !!
    My University teacher gave me an exercize where he askes to calculate the minimum,medium and maximum cubic capacities in an ArrayList<Cars> carList .
    I didn't find problems to make a new method for searching the minum and maximum cubic capacities,but I could not think a way to make the method for the Average cubic capacity value.
    For the min and max searches I wrote down :
    public Car searchForMinCubicCapacityValue()
    Car car= carList.get(0);
    for(Car aCar : carList)
    if(aCar.getCubicCapacity() <= car.getCubicCapacity())
    minimumCar = aCar; (where minimumCar is an Instance Variable)
    return minimumCar;
    The same is for the method searchForMaxCubicCapacityValue() but I put >= indeed and I have used the Instance Variable maximumCar.
    How could I write down the method searchForAverageCubicCapacityValue() ?
    I really need your help please !...
    I have to know for next week test ! In this test I'll have to write down a class with these same methods and others !
    Thanks in advance !

    Sorry ! I'll change the name of my 3 methods !
    I would calculate by hand an average just adding up
    the cubic capacities and then dividing the result of
    this addition by the total number of cars.Right.
    But I have tried to write down this one in the method
    for an Average cubic capacity but I get the same
    result of the maximum cubic capacity.Well, then the Java you wrote doesn't do what you described above. If you show the code, someone can help you find your error.
    When you post code, please use[code] and [/code] tags as described in Formatting tips on the message entry page. (http://forum.java.sun.com/help.jspa?sec=formatting) It makes it much easier to read.
    But I know that
    there is an average value in my ArrayList !Of course there is. Any collection of values has an average.
    I think this thing happens because the result of the
    division is a number that doesn't exist in my
    ArrayList.The average may very well not be a numbre in the list. If the list contains only 0 and 100, the average is 50, which is not in the list.

  • Need help with drawLine method

    Hello,
    I've been having trouble with a recent programming assignment and the prof isn't being very helpful. I need to call the drawLine method to plot a line between (0,0) and two coordinates entered by the user; is there a way to do this without a JPanel? Here are the specs:
    I've already done Part 1., just posting it to give a complete representation of the assignment.
    Part 1. Implement a ComplexNumber class to represent complex numbers (z = a + bi).
    1) Instance variables:
    private int real; /* real part */
    private int imag; /* imaginary part */
    2) Constructor:
    public ComplexNumber ( int realVal, int imagVal )
    { /* initialize real to realVal and imag to imagVal */ }
    3) Get/Set functions:
    public int getReal ( )
    { /* returns the real part */ }
    public int getImag ( )
    { /* returns the imaginary part */ }
    public void setReal ( int realVal )
    { /* sets real to realVal */ }
    public void setImag ( int imagVal )
    { /* sets imag to imagVal */ }
    Part 2. Implement a ComplexNumberPlot class (with a main method) that gets complex
    numbers from the user and plots them. The user will be prompted a complex number until
    he/she enters 0. The numbers will be input from the keyboard (System.in) and displayed
    in the plot as they are entered. Assume that the user will enter the numbers in blank
    separated format. For example, if the user wants to enter three complex numbers: 3 + 4i,
    5 + 12i, and 15 + 17i, the input sequence will be:
    3 4
    5 12
    15 17
    0 0
    To plot a complex number, you need to draw a line between (0,0) and (real, imag) using
    the drawLine method.
    Name your classes as ComplexNumber and ComplexNumberPlot.
    For simplicity, you can assume that the complex numbers input by the user fall
    into the first quadrant of the complex plane, i.e. both real and imaginary values
    are positive.
    Thanks for any help!

    Ok I've made some progress, here is what I've got.
    public class ComplexNumber
    private int real;
    private int imag;
    public ComplexNumber (int realVal, int imagVal)
    real = realVal;
    imag = imagVal;
    public int getReal()
    return real;
    public int getImag()
    return imag;
    public void setReal(int realVal)
    real = realVal;
    public void setImag(int imagVal)
    imag = imagVal;
    import java.util.Scanner;
    import java.awt.*;
    import javax.swing.*;
    public class ComplexNumberPlot
    public static void main (String [] args)
    ComplexNumber num = new ComplexNumber (1,0);
    Scanner scan = new Scanner (System.in);
    System.out.println("Enter a complex number(s):");
    num.setReal(scan.nextInt());
    num.setImag(scan.nextInt());
    while (num.getReal() + num.getImag() != 0)
    num.setReal(scan.nextInt());
    num.setImag(scan.nextInt());
    System.out.println();
    JFrame frame = new JFrame ("ComplexNumberPlot");
    frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
    ComplexPanel panel = new ComplexPanel();
    frame.getContentPane().add(panel);
    frame.pack();
    frame.setVisible(true);
    class ComplexPanel extends JPanel
    public ComplexPanel()
    setPreferredSize (new Dimension(150,150));
    public void PaintComponent (Graphics page)
    super.paintComponent(page);
    page.drawLine(0,0,100,100);
    However
    1) The JPanel pops up but no line is drawn.
    2) I am not sure how to get the variables I'm scanning for to work in the drawLine method
    Thanks for all your help so far.

  • Need help with calling method

    I'm new to Java, trying to pass a required class so I can graduate this semester, and I need help figuring out what is wrong with the code below. My assignment is to create a program to convert celsius to fahrenheit and vice versa using Scanner for input. The program must contain 3 methods - main, convert F to C, method, and convert C to F method. Requirements of the conversion methods are one parameter which is an int representing temp, return an int representing calculated temp after doing appropriate calculation, should not display info to user, and should not take in info from user.
    The main method is required to ask the user to input a 1 for converting F to C, 2 for C to F, and 3 to end the program. It must include a while loop that loops until the user enters a 3, ask the user to enter a temp, call the appropriate method to do the conversion, and display the results. I'm having trouble calling the conversion methods and keep getting the following 2 compiler errors:
    cannot find symbol
    symbol : method farenheitToCelsius(int)
    location: class WondaPavoneTempConverter
    int celsius = farenheitToCelsius(intTemp);
    ^
    cannot find symbol
    symbol : method celsiusToFarenheit(int)
    location: class WondaPavoneTempConverter
    int farenheit = celsiusToFarenheit(intTemp);
    The code is as follows:
    public static void main(String[] args) {
    // Create a scanner
    Scanner scanner = new Scanner(System.in);
    // Prompt the user to enter a temperature
    System.out.println("Enter the temperature you wish to convert as a whole number: ");
    int intTemp = scanner.nextInt();
    System.out.println("You entered " + intTemp + " degrees.");
    // Prompt the user to enter "1" to convert to Celsius, "2" to convert to
    // Farenheit, or "3" to exit the program
    System.out.println("Enter 1 to convert to Celsius, 2 to convert to Farenheit, or 3 to exit.");
    int intConvert = scanner.nextInt();
    // Convert temperature to Celsius or Farenheit
    int celsius = farenheitToCelsius(intTemp);
    int farenheit = celsiusToFarenheit(intTemp);
    while (intConvert >= 0) {
    // Convert to Celsius
    if (intConvert == 1) {
    System.out.println("Celsius is " + celsius + " degrees.");
    // Convert to Farenheit
    else if (intConvert == 2) {
    System.out.println("Farenheit is " + farenheit + " degrees.");
    // Exit program
    else if (intConvert == 3) {
    break;
    else {
    System.out.println("The number you entered is invalid. Please enter 1, 2, or 3.");
    //Method to convert Celsius to Farenheit
    public static int celsiusToFahrenheit(int cTemp) {
    return (9 / 5) * (cTemp + 32);
    //Method to convert Farenheit to Celsius
    public static int fahrenheitToCelsius(int fTemp) {
    return (5 / 9) * (fTemp - 32);
    I readily admit I'm a complete dunce when it comes to programming - digital media is my area of expertise. Can anyone point me in the right direction? This assignment is due very soon. Thanks.

    1) consider using a boolean variable in the while statement and converting it to true if the input is good.
    while (inputNotValid)
    }2) put the code to get the input within the while loop. Try your code right now and enter the number 30 when your menu requests for input and you'll see the infinite loop.... and why you need to request input within the loop.
    3) Fix your equations. You are gonig to have to do some double calcs, even if you convert it back to int for the method return. Otherwise the results are just plain wrong. As a good test, put in the numbers -40, 0, 32, 100, and 212. Are the results as expected? (-40 is the only temp that is the same for both cent and fahr). I recommend doing double calcs and then casting the result to int in the return. for example:
    int a = (int) (20 + 42.0 / 3);  // the 42.0 forces the compiler to do double calc.4) One of your equations may still be plain wrong even with this fix. Again, run the test numbers and see.
    5) Also, when posting your code, please use code tags so that your code will be well-formatted and readable. To do this, either use the "code" button at the top of the forum Message editor or place the tag &#91;code&#93; at the top of your block of code and the tag &#91;/code&#93; at the bottom, like so:
    &#91;code&#93;
      // your code block goes here.
    &#91;/code&#93;

  • Need Urgent Help with static methods!!!!

    If I have a static method to which a variable is being passed...for example
    static String doSomething(String str)
    //..doSomething with str and return
    If the method is invoked a second time by a separate entity when it is already in use by one entity(!!!not entity beans) .... will this lead to the second invocation overwriting str while the method is already in use and thus corrupting the variable that the method was passed from the first entity?

    It's also a common misunderstanding about parameters. The method does not receive a variable as its parameter, it receives a reference to an object. And inside the method, the parameter acts just the same as a local variable would. So if two threads call the method (static or not), each thread has its own copy of the parameter.

  • Need help with a method

    I am re-writing this method because it does not return the expected data. I
    am still somewhat new to coding in Forte. Please help if you can. The
    error exception message I receive when I run is.....
    This error is a TOOL CODE ERROR
    Detected In:
    Class: RPTClientNumberList
    Method: DBCursor::Open
    Location: 0
    Forte Error Message is:
    No input values supplied for the SQL statement.
    Additional Information:
    **** End of Error ****
    No matter what changes I make to the SQL I still receive this error.
    //: Parameters: pReportCriteria : ClientNumberListReportCriteria
    //: Returns: Array of ClientNumberListReportData
    //: Purpose: To get the data required for the ClientNumberListReportData.
    //: Logic
    //: History: mm/dd/yy xxx comment
    lClientTransfersArray : Array of ClientNumberListReportData = new();
    lResultArray : Array of ClientNumberListReportData =
    new();
    lReportData : ClientNumberListReportData;
    lReportInfo :
    ClientNumberListReportTransactions;
    lThis : TextData =
    'ReportSQLAgent.SelectClientNumberListReportData()';
    lSQL : TextData = new();
    lSQL.SetValue(
    'SELECT C.ClientName aClientName, \
    CN.ClientNumber aClientNumber, \
    CN.ClientNumberID aClientNumberID, \
    T.TeamNumber aIsTeamID, \
    AM.FirstName aFirstName, \
    AM.MiddleName aMiddleName, \
    AM.LastName aLastName \
    FROM SUPER_DBA.Client C, \
    SUPER_DBA.ClientN CN, \
    SUPER_DBA.Team T, \
    SUPER_DBA.OASUSER AM \
    WHERE CN.ClientID = C.ClientID and \
    CN.ISTeamID = T.TeamID
    and \
    CN.IsActive = \'Y\' AND
    CN.AccountMgrID = AM.UserID ');
    // If the criteria contains an ISTeamID, search by it.
    if pReportCriteria.aISTeamID <> cEmptyDropListValue then
    lSQL.concat( ' and CN.ISTeamID = ');
    lSQL.concat( pReportCriteria.aISTeamID );
    end if;
    begin transaction
    lDynStatement : DBStatementHandle;
    lInputDesc : DBDataset;
    lOutputDesc : DBDataset;
    lOutputData : DBDataset;
    lRowType : Integer;
    lStatementType : Integer;
    // The prepare method parses the SQL statement, verifying the
    // syntax and returns a statement identifier (the handle
    lDynStatement)
    // to use as a reference
    lDynStatement = DefaultDBSession.prepare( lSQL, lInputDesc,
    lStatementType );
    // The opencursor method positions the cursor before the first row
    // in the result set
    lRowType = DefaultDBSession.OpenCursor( lDynStatement, lInputDesc,
    lOutputDesc );
    lNumRows : Integer;
    while true do
    lNumRows = DefaultDBSession.FetchCursor( lDynStatement,
    lOutputData );
    if lNumRows <= 0 then
    exit;
    end if;
    lReportData = new();
    lReportData.aFirstName = TextData(
    lOutputData.GetValue(ColumnName='aFirstName')).value;
    lReportData.aMiddleName = TextData(
    lOutputData.GetValue(ColumnName='aMiddleName')).value;
    lReportData.aLastName = TextData(
    lOutputData.GetValue(ColumnName='aLastName')).value;
    lReportData.aClientName = TextData(
    lOutputData.GetValue(ColumnName='aClientName')).value;
    lReportData.aClientNumber = DoubleNullable(
    lOutputData.GetValue(ColumnName='aClientNumber')).TextValue.value;
    lReportData.aClientNumberID = DoubleNullable(
    lOutputData.GetValue(ColumnName='aClientNumberID')).integervalue;
    lReportData.aIsTeamID = IntegerNullable(
    lOutputData.GetValue(ColumnName='aIsTeamID')).TextValue.value;
    lResultArray.AppendRow( lReportData );
    end while;
    // Close the cursor
    DefaultDBSession.CloseCursor( lDynStatement );
    // Remove the cursor to free resources
    DefaultDBSession.RemoveStatement( lDynStatement );
    end transaction;
    for lEach in lResultArray do
    lHistorySQL : TextData = new();
    lHistorySQL.SetValue(
    'SELECT CNH.isActive aIsActive, \
    T.TeamNumber aTeamID, \
    CNH.ModifyDateTime
    aTransactionDate \
    FROM SUPER_DBA.ClientNH CNH, \
    SUPER_DBA.Team T \
    WHERE CNH.ISTeamID = T.TeamID and \
    CNH.ClientNumberID =
    :lResultArray.aClientNumberID ');
    // If a date range was specified, include it in the SQL
    if NOT pReportCriteria.aStartDate.IsNull then
    lHistorySQL.concat( ' and CNH.ModifyDateTime between
    :pReportCriteria.aStartDate ');
    lHistorySQL.concat( ' and :pReportCriteria.aEndDate ');
    end if;
    begin transaction
    lDynStatement : DBStatementHandle;
    lInputDesc : DBDataset;
    lOutputDesc : DBDataset;
    lOutputData : DBDataset;
    lRowType : Integer;
    lStatementType : Integer;
    // The prepare method parses the SQL statement, verifying
    the
    // syntax and returns a statement identifier (the handle
    lDynStatement)
    // to use as a reference
    lDynStatement = DefaultDBSession.prepare( lHistorySQL,
    lInputDesc, lStatementType );
    // The opencursor method positions the cursor before the
    first row
    // in the result set
    lRowType = DefaultDBSession.OpenCursor( lDynStatement,
    lInputDesc, lOutputDesc );
    lNumRows : Integer;
    while true do
    lNumRows = DefaultDBSession.FetchCursor(
    lDynStatement, lOutputData );
    if lNumRows <= 0 then
    exit;
    end if;
    lReportInfo = new();
    lReportInfo.aIsActive = TextData(
    lOutputData.GetValue(ColumnName='aIsActive')).value;
    lReportInfo.aISTeamID =
    IntegerNullable(
    lOutputData.GetValue(ColumnName='aTeamID')).TextValue.value;
    lReportInfo.aTransactionDate = DateTimeData(
    lOutputData.GetValue(ColumnName='aTransactionDate'));
    lResultArray.AppendRow( lReportData );
    end while;
    // Close the cursor
    DefaultDBSession.CloseCursor( lDynStatement );
    // Remove the cursor to free resources
    putline( '%1: Removing the cursor.', lThis );
    DefaultDBSession.RemoveStatement( lDynStatement );
    end transaction;
    lLastTeamNumber : string = cEmptyText;
    lKeepRecord : boolean = False;
    if lReportInfo.aISTeamID <> lLastTeamNumber then
    lLastTeamNumber = lReportInfo.aISTeamID;
    lReportInfo.aTransactionDescription = 'New Team Assignment';
    lResultArray.appendRow( lReportInfo );
    end if;
    if lReportInfo.aIsActive = 'N' then
    lReportInfo.aTransactionDescription = 'Team Number Deleted';
    lResultArray.appendRow( lReportInfo );
    end if;
    end for;
    // Success! Excellent!! Return the ClientNumberListReportData!
    return lResultArray;
    exception
    when e : GenericException do
    LogException( e, lThis );
    raise e;
    Lisa M. Tucci - Applications Programmer
    Business Applications Support and Development - West Corporation
    tel.: (402) 964-6360 ex: 208-4360 stop: W8-IS e-mail: lmtucciwest.com

    I am re-writing this method because it does not return the expected data. I
    am still somewhat new to coding in Forte. Please help if you can. The
    error exception message I receive when I run is.....
    This error is a TOOL CODE ERROR
    Detected In:
    Class: RPTClientNumberList
    Method: DBCursor::Open
    Location: 0
    Forte Error Message is:
    No input values supplied for the SQL statement.
    Additional Information:
    **** End of Error ****
    No matter what changes I make to the SQL I still receive this error.
    //: Parameters: pReportCriteria : ClientNumberListReportCriteria
    //: Returns: Array of ClientNumberListReportData
    //: Purpose: To get the data required for the ClientNumberListReportData.
    //: Logic
    //: History: mm/dd/yy xxx comment
    lClientTransfersArray : Array of ClientNumberListReportData = new();
    lResultArray : Array of ClientNumberListReportData =
    new();
    lReportData : ClientNumberListReportData;
    lReportInfo :
    ClientNumberListReportTransactions;
    lThis : TextData =
    'ReportSQLAgent.SelectClientNumberListReportData()';
    lSQL : TextData = new();
    lSQL.SetValue(
    'SELECT C.ClientName aClientName, \
    CN.ClientNumber aClientNumber, \
    CN.ClientNumberID aClientNumberID, \
    T.TeamNumber aIsTeamID, \
    AM.FirstName aFirstName, \
    AM.MiddleName aMiddleName, \
    AM.LastName aLastName \
    FROM SUPER_DBA.Client C, \
    SUPER_DBA.ClientN CN, \
    SUPER_DBA.Team T, \
    SUPER_DBA.OASUSER AM \
    WHERE CN.ClientID = C.ClientID and \
    CN.ISTeamID = T.TeamID
    and \
    CN.IsActive = \'Y\' AND
    CN.AccountMgrID = AM.UserID ');
    // If the criteria contains an ISTeamID, search by it.
    if pReportCriteria.aISTeamID <> cEmptyDropListValue then
    lSQL.concat( ' and CN.ISTeamID = ');
    lSQL.concat( pReportCriteria.aISTeamID );
    end if;
    begin transaction
    lDynStatement : DBStatementHandle;
    lInputDesc : DBDataset;
    lOutputDesc : DBDataset;
    lOutputData : DBDataset;
    lRowType : Integer;
    lStatementType : Integer;
    // The prepare method parses the SQL statement, verifying the
    // syntax and returns a statement identifier (the handle
    lDynStatement)
    // to use as a reference
    lDynStatement = DefaultDBSession.prepare( lSQL, lInputDesc,
    lStatementType );
    // The opencursor method positions the cursor before the first row
    // in the result set
    lRowType = DefaultDBSession.OpenCursor( lDynStatement, lInputDesc,
    lOutputDesc );
    lNumRows : Integer;
    while true do
    lNumRows = DefaultDBSession.FetchCursor( lDynStatement,
    lOutputData );
    if lNumRows <= 0 then
    exit;
    end if;
    lReportData = new();
    lReportData.aFirstName = TextData(
    lOutputData.GetValue(ColumnName='aFirstName')).value;
    lReportData.aMiddleName = TextData(
    lOutputData.GetValue(ColumnName='aMiddleName')).value;
    lReportData.aLastName = TextData(
    lOutputData.GetValue(ColumnName='aLastName')).value;
    lReportData.aClientName = TextData(
    lOutputData.GetValue(ColumnName='aClientName')).value;
    lReportData.aClientNumber = DoubleNullable(
    lOutputData.GetValue(ColumnName='aClientNumber')).TextValue.value;
    lReportData.aClientNumberID = DoubleNullable(
    lOutputData.GetValue(ColumnName='aClientNumberID')).integervalue;
    lReportData.aIsTeamID = IntegerNullable(
    lOutputData.GetValue(ColumnName='aIsTeamID')).TextValue.value;
    lResultArray.AppendRow( lReportData );
    end while;
    // Close the cursor
    DefaultDBSession.CloseCursor( lDynStatement );
    // Remove the cursor to free resources
    DefaultDBSession.RemoveStatement( lDynStatement );
    end transaction;
    for lEach in lResultArray do
    lHistorySQL : TextData = new();
    lHistorySQL.SetValue(
    'SELECT CNH.isActive aIsActive, \
    T.TeamNumber aTeamID, \
    CNH.ModifyDateTime
    aTransactionDate \
    FROM SUPER_DBA.ClientNH CNH, \
    SUPER_DBA.Team T \
    WHERE CNH.ISTeamID = T.TeamID and \
    CNH.ClientNumberID =
    :lResultArray.aClientNumberID ');
    // If a date range was specified, include it in the SQL
    if NOT pReportCriteria.aStartDate.IsNull then
    lHistorySQL.concat( ' and CNH.ModifyDateTime between
    :pReportCriteria.aStartDate ');
    lHistorySQL.concat( ' and :pReportCriteria.aEndDate ');
    end if;
    begin transaction
    lDynStatement : DBStatementHandle;
    lInputDesc : DBDataset;
    lOutputDesc : DBDataset;
    lOutputData : DBDataset;
    lRowType : Integer;
    lStatementType : Integer;
    // The prepare method parses the SQL statement, verifying
    the
    // syntax and returns a statement identifier (the handle
    lDynStatement)
    // to use as a reference
    lDynStatement = DefaultDBSession.prepare( lHistorySQL,
    lInputDesc, lStatementType );
    // The opencursor method positions the cursor before the
    first row
    // in the result set
    lRowType = DefaultDBSession.OpenCursor( lDynStatement,
    lInputDesc, lOutputDesc );
    lNumRows : Integer;
    while true do
    lNumRows = DefaultDBSession.FetchCursor(
    lDynStatement, lOutputData );
    if lNumRows <= 0 then
    exit;
    end if;
    lReportInfo = new();
    lReportInfo.aIsActive = TextData(
    lOutputData.GetValue(ColumnName='aIsActive')).value;
    lReportInfo.aISTeamID =
    IntegerNullable(
    lOutputData.GetValue(ColumnName='aTeamID')).TextValue.value;
    lReportInfo.aTransactionDate = DateTimeData(
    lOutputData.GetValue(ColumnName='aTransactionDate'));
    lResultArray.AppendRow( lReportData );
    end while;
    // Close the cursor
    DefaultDBSession.CloseCursor( lDynStatement );
    // Remove the cursor to free resources
    putline( '%1: Removing the cursor.', lThis );
    DefaultDBSession.RemoveStatement( lDynStatement );
    end transaction;
    lLastTeamNumber : string = cEmptyText;
    lKeepRecord : boolean = False;
    if lReportInfo.aISTeamID <> lLastTeamNumber then
    lLastTeamNumber = lReportInfo.aISTeamID;
    lReportInfo.aTransactionDescription = 'New Team Assignment';
    lResultArray.appendRow( lReportInfo );
    end if;
    if lReportInfo.aIsActive = 'N' then
    lReportInfo.aTransactionDescription = 'Team Number Deleted';
    lResultArray.appendRow( lReportInfo );
    end if;
    end for;
    // Success! Excellent!! Return the ClientNumberListReportData!
    return lResultArray;
    exception
    when e : GenericException do
    LogException( e, lThis );
    raise e;
    Lisa M. Tucci - Applications Programmer
    Business Applications Support and Development - West Corporation
    tel.: (402) 964-6360 ex: 208-4360 stop: W8-IS e-mail: lmtucciwest.com

  • Help with setSelectionPath() method (JTree)

    Hi. I'm having problems with manually selecting a node when the structure of the tree changes (nodes inserted or removed). This fails when I insert a second node (NullPointerException).
    Here's the code and Thanks:
        public void slideAdded(Slide slide) {
            DefaultMutableTreeNode newSlide = new DefaultMutableTreeNode(slide, true);
            model.insertNodeInto(newSlide, treeRootNode, treeRootNode.getChildCount());
            model.nodeStructureChanged(treeRootNode);
            tree.setSelectionPath(new TreePath(model.getPathToRoot(treeRootNode.getLastChild()))); //seems not to work properly
            selectedNode = (DefaultMutableTreeNode) tree.getSelectionPath().getLastPathComponent();
        }Oh... the problem is that the getPathToRoot() doesn't return a TreePath Object... what can I do?
    Edited by: Akcents on May 2, 2008 10:59 PM

    Still posting in the wrong forum.
    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.

Maybe you are looking for

  • Xml-sax

    hi all i am getting the following error while running a java program...can anyone help me in setting the sax driver...? log: java.lang.ClassNotFoundException: org.apache.crimson.parser.XMLReaderImpl      at org.xml.sax.helpers.XMLReaderFactory.create

  • Replacing all occurrences of characters in a string with one new character?

    Hi there, I'm looking for a way that I could replace all occurrences of a set of specific characters with just one new character for each occurrence. For example if I have a string which is "word1...word2.......word3....word4............word5" how wo

  • How to Create a Generic Delta Datasource

    Hi All, I have created a extractor thru RSO2 using a table. The table consist of a time field which i set it to the timestamp field. After initlializing the delta upload successfully, when i run delta upload, no data has been uploaded even having mad

  • ITunes not capable of shuffling Audiobooks???

    Hi. I have a playlist with hundreds of Audiobooks on it. I would like to listen in a random order. (So I don't get sick of one Author) So I turn shuffle on and after one track is finished playing, instead of playing another track at random, the play

  • Dual monitors dont work with gaming?

    I have a video card (just one with dual output) that allows me to run separate programs on each monitor, but not if I am running a video game. Are all VC like this where I cant game on one monitor and keep Excel up on the other?  Thanks