Help with short method explanation..!!

Hi guys can someone explain what each line does
public MyComboModel(Vector cars){      
       for (int k=0; k<cars.size(); k++) {        
      String car = (String)cars.elementAt(k);        
      addElement( car);
}

<Jessica Simpson mode>
Well, like, this is like, so easy. I mean, oh... my.... gawd!
A Vector is like, you know, a collection of stuff. The for loop does this thingy where it like, iterates through that collection. And as it loops, it, like, gets each item from the Vector thingy and casts it to a String thingy. Then it, like, adds it to some kind of list.
Does that, like, help any?
How does my hair look?

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

  • Value help with short text

    Hi gurus,
    I'm trying to create a input value help with the records from my internal table but I woulkd like also to put the short when the popup displays.
    Actually I only have the records.
    SELECTION-SCREEN BEGIN OF BLOCK ref WITH FRAME TITLE text-t03.
    SELECT-OPTIONS:
                    s_kstar FOR i_cska-kstar.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_kstar-low.
      PERFORM search_kstar USING s_kstar-low.
    FORM search_kstar
                     using kstar type cska-kstar.
      SELECT * FROM cska
                   INTO CORRESPONDING FIELDS OF TABLE i_cska
                   WHERE kstar LIKE '08%'
                   OR    kstar LIKE '008%'
                   OR    kstar LIKE '0008%'.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield    = 'KSTAR'
          dynprofield = 's_kstar'
          dynpprog    = sy-cprog
          dynpnr      = sy-dynnr
          value_org   = 'S'
        TABLES
          value_tab   = i_cska.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CALL FUNCTION 'HELP_VALUES_GET'
           EXPORTING
                fieldname        =  'KSTAR'
                tabname          =  'i_cska'
           IMPORTING
                SELECT_VALUE     =   kstar.
    ENDFORM.                    " SEARCH_KSTAR
    Anybody would a solution.
    Thx in advance for your help.
    Mohamed.

    Hi Mohamed,
    Check the Following.
    "  Implement your own search Help as below
    PARAMETERS : carrid TYPE spfli-carrid,
                 connid TYPE spfli-connid,
                 fldate TYPE sflight-fldate.
    DATA : itab TYPE TABLE OF sflight WITH HEADER LINE.
    DATA : fmap TYPE TABLE OF dselc WITH HEADER LINE.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR carrid." If it is a selection Screen
    else in PROCESS ON VALUE REQUEST
      SELECT * FROM sflight INTO TABLE itab.
      SORT itab BY carrid connid fldate.
      DELETE ADJACENT DUPLICATES FROM itab
      COMPARING carrid connid fldate.
      fmap-fldname = 'CARRID'.
      fmap-dyfldname = 'CARRID'.
      APPEND fmap.
      fmap-fldname = 'CONNID'.
      fmap-dyfldname = 'CONNID'.
      APPEND fmap.
      fmap-fldname = 'FLDATE'.
      fmap-dyfldname = 'FLDATE'.
      APPEND fmap.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
         ddic_structure         = 'SFLIGHT'
          retfield               = 'CARIID'
    *     PVALKEY                = ' '
         dynpprog               = sy-repid
         dynpnr                 = sy-dynnr
         DYNPROFIELD            = 'CARRID'
    *     STEPL                  = 0
    *     WINDOW_TITLE           =
    *     VALUE                  = ' '
         value_org              = 'S'
    *     MULTIPLE_CHOICE        = ' '
    *     DISPLAY                = ' '
    *     CALLBACK_PROGRAM       = ' '
    *     CALLBACK_FORM          = ' '
    *     MARK_TAB               =
    *   IMPORTING
    *     USER_RESET             =
        TABLES
          value_tab              = itab
    *     FIELD_TAB              =
    *     RETURN_TAB             =
         dynpfld_mapping        = fmap
    *   EXCEPTIONS
    *     PARAMETER_ERROR        = 1
    *     NO_VALUES_FOUND        = 2
    *     OTHERS                 = 3
                ." Just Execute this pilot program and verify
      IF sy-subrc  0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Cheerz
    Ram

  • 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.

  • 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 calling methods of different classes

    I have two classes. In class A I read a line of input from the console
    myVar= x.readLine();
    then I call a method of the same class (A)
    methodA(); i get NULLPOINTEREXCEPTION here
    in this method I wish to call another method but this time of class B so I create an instance of class B in class A
    private B instanceVar;
    and then proceed to create the method call to class B
    instanceVar.methodB(myVar); i get NULLPOINTEREXCEPTION here
    What am I doing wrong?

    What am I doing wrong?Not posting a short snippet of java code that demonstrates your problem.
    In class A I read a line of input from the console
    myVar= x.readLine();
    How is that related to the NPE's?
    then I call a method of the same class (A)
    methodA(); i get NULLPOINTEREXCEPTION hereSomething is probably wrong in methodA(). Impossible to say anything more with the information given.
    private B instanceVar;
    and then proceed to create the method call to class B
    instanceVar.methodB(myVar); i get NULLPOINTEREXCEPTION hereDid you ever assign instanceVar to an actual object with something like instanceVar = new B(); ?

  • 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 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;

  • 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.

Maybe you are looking for

  • Can I use my macbook with a mac mini

    can I use my macbook with a mac mini

  • Lost music

    Suddenly, after using ipod mini for a year, I'm getting the message 'songs on the ipod kennyz ipod cannot be updated because all of the playlists selected for updating no longer exist.' yet i swear to god I've done nothing out of the ordinary!!!

  • Import JBuilder into Sun Java Studio Enterprise 8

    I have a few JBuilder projects that I would like to import into SJSE8. I have read all the guides for migrating projects from JBuilder but I cannot see how I actually get the Import Project module. SJSE8 is supposed to be built on NetBeans5.5 but whe

  • Unloading SWF movie

    Hi, I've been working on a CD-Rom presentation with Flash and so far I was mostly using AS1 and AS2 to built it. I started to learn some AS3 for a part of the presentation but now I'm running into issue, here's the main one: I'm loading different SWF

  • For Multi value attributes, how we can view only the most recent value?

    Where we can set what in endeca servers (MDEX, Clover & Studio) to view only the most recent value of a multi assign value attribute on Studio server?