How to get value of a nested object?!!

I am writing a small game program in java(applet). I am not getting the value of a nested object in the paint method. Please help.
the text marked as code is wrong. Can u tell me a simple method?
s1.a[0].x will give error. What should I use?
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
class SnakeBit
     int x,y; //x and y are coordinates
     int position;
public SnakeBit(int x, int y)
     this.x=x;
     this.y=y;
public SnakeBit copy(SnakeBit a)
     this.x=a.x;
     this.y=a.y;
     return this;
public int getValueX()
     int a;
     a=this.x;
     return a;
public int getValueY()
     int b;
     b=this.y;
     return b;
}//end of class SnakeBit.
class Cell
     public int x,y;
//************************************************Snake class***************************************
class Snake
     public Snake()
                         SnakeBit a[]=new SnakeBit[5];
                         a[0]=new SnakeBit(8,4);
     public static void main(String args[])
                         SnakeBit a[]=new SnakeBit[5];
                         a[0]=new SnakeBit(8,4);
                         a[1]=new SnakeBit(8,5);
                         a[2]=new SnakeBit(8,6);
                         a[3]=new SnakeBit(9,6);
                         a[4]=new SnakeBit(10,6);
                         a[5]=new SnakeBit(10,7);
                         a[6]=new SnakeBit(10,8);
          Snake a1=new Snake();
     public void up(SnakeBit a[])
          move(a);
          a[0].y=a[0].y-1;
     public void right(SnakeBit a[])
          move(a);
          a[0].x=a[0].x+1;
     public void left(SnakeBit a[])
          move(a);
          a[0].x=a[0].x-1;
     public void down(SnakeBit a[])
          move(a);
          a[0].x=a[0].y+1;
     public void move(SnakeBit a[])
          a[6].copy(a[5]);
          a[5].copy(a[4]);
          a[4].copy(a[3]);
          a[3].copy(a[2]);
          a[2].copy(a[1]);
          a[1].copy(a[0]);
}//end of class Snake.
public class Game1 extends Applet //implements KeyListener
     Snake s1;
     SnakeBit aa;
     int sizeOfCell=10; //default=10
     int startX=20; //starting x position of board.default=20
     int startY=20;     //starting y position of board.
     int maxX=200;          //max x value of board, ie width. default=200
     int maxY=200;          //max y value of board ie height.
     boolean drawBoard;
     //int arrays which will store the values of the objects
     int x[]=new int[5];
     int y[]=new int[5];
     public void init()
          s1=new Snake();
          //drawBoard=false;
          //x=s1.getValueX();
          //y=s1.getValueY();
          //aa = s1.a[0];
     public void paint(Graphics g)
     //public void Mpaint(Graphics g, Snake s1)
          //if (drawBoard==false)
               drawBoard=true;
               g.setColor(Color.cyan);
                    for(int i=startX;i<=maxX;i=i+sizeOfCell)
                    for(int j=startY;j<=maxY;j=j+sizeOfCell)
                         g.fillRect(i,j,sizeOfCell,sizeOfCell);
               g.setColor(Color.red);
                              for(int i=startX;i<=maxX;i=i+sizeOfCell)
                              for(int j=startY;j<=maxY;j=j+sizeOfCell)
                                   g.drawRect(i,j,sizeOfCell,sizeOfCell);
          for(int i=0;i<7;i++)
<code>
          g.drawRect(s1.a[0].x * sizeOfCell, s1.a[0].y*sizeOfCell,sizeOfCell,sizeOfCell);
</code>
}//end of class Game.

Those who feel the program is too big to solve,( actually the code is not well written, and documentation is nill)
I will try to explain in my own words.
There are only 3 classes
1)SnakeBit
2)Snake
3)Game
SnakeBits draws a small part of a snake.
Snake draws the whole snake.
In the constructor of the Snake class , one SnakeBit is created.(Actually we create 5 or more, but right now to make the problem clear, I have created only one.)
     SnakeBit a[]=new SnakeBit[5];
     a[0]=new SnakeBit(8,4);
In the game class, a Snake is created.
In the game class, I can access the members of the Snake class. But I cannot access the members of the SnakeBit class.
I need to access the members of the SnakeBit class from the paint method. otherwise How am I going to draw it on the screen.
So tell me a way to do it.
I want to get the x and y variable of the SnakeBit class from the Game class.
Please help.

Similar Messages

  • How to get Date Format from Local Object.

    Hi All,
    I am new to Web Channel.
    I need to know Date format From date of locale.
    suppose there is a date "01/25/2010" date in date field I want to get string "mm/dd/yyyy". Actually I have to pass date format to backend when I call RFC. 
    Is there any way to get Date format from "Locale" object. I should get date format for local object
    I get local object from "UserSessionData" object but how to get Date format from it.
    I am not looking for Date value. I am looking for current local date format ("mm/dd/yyyy or dd/mm/yyyy or mon/dd/yyyy) whatever local date format.  I could not find example which show how to get date format from "Locale" object.
    Any help will be appreciated with rewards.
    Regards.
    Web Channel

    Hi,
    You can get it from "User" or "Shop" business object.
    Try to get User or Shop Business Object as shown below.
    BusinessObjectManager bom = (BusinessObjectManager) userSessionData.getBOM(BusinessObjectManager.ISACORE_BOM);
    User user = bom.getUser();
    char decimalNotation = user.getDecimalPointFormat().getGroupingSeparator();
    If you are seeing "1,234.00" then above code will return "."
    I hope this information help you to resolve your issue.
    eCommerce Developer.

  • How to get value from list item

    Hi all,
    How to get value from list item?
    I have a problem with the List Item object
    in the Oracle forms.
    How can I retrieve the selected item from
    a list ?
    I didn't find any function like 'list.GET_
    SELECTED_ITEM()'...
    thanks
    Bala

    Hello,
    You get the value as for any other Forms item:
    :value := :block.list_tem ;Francois

  • How to get value in showModalDialog()

    Hi,
    I would like to know how to get value pass into showModalDialog() to be used by the server (using request.getParameter())
    TQ

    please try out this kind of code
    <script language="javascript">
         function trial(){
              var retVal = new Object();
              retVal = ShowModalDialog("ur JSp");
    </script>
    <script>
    <form >
    <input type="hidden" name ="mylink "value= javascript:trial();>
    </form>
    <%
         String str=request.getParameter("mylink");
    %>
    and plz let me know .. if it works

  • How to get value of a textfield which has been set as Renderd false.

    Hi all
    how to get value of a TEXTFIELD which has been set as Renderd false.
    i am getting the value of this textfield from an lov but dont want to show it to the user.
    getting error as:
    attribute xxxx required for view object yyyyy.
    pls help
    naveen

    You can create item inside your LOV region, set the item style to formValue. You can associate this to a View Object field. It can also act as mirror of any other text input field.
    FormValue can hold the value and will not be diaplyed to user. You can read value from it controller
    example
    OAFormValueBean orgValue = (OAFormValueBean)webBean.findChildRecursive("OrgIdFormVal");
    Or you can read it fro the VO associated with this form value.

  • How to get value by jstl?

    select IEPort,seqNo,IEDate,trafMode from TImport
    this is in hibernate hql
    List queryResult = dao.getList(session, form);so in the list is not a bean but an Object, so in the Object do not hava attribute name, i don't know how to get value by JSTL in the jsp, who can help me

    JSTL can figure out what the specific type of the Object is on its own. Just reference the attributes of your bean using the expression language like you would normally do. If you are uncertain print out the classname of the objects in the list like this:
    ${obj.class.name}where obj is an object from the list. This should print out the name of your beans if hibernate did its job properly. JSTL will know what properties these objects has even if you only pass it an Object reference.

  • How to get values/data stored in the database into a list-item.

    how to get values/data stored in the database into a list-item.
    i tried to make a list item without any values assigned to it...but i got the below error.
    FRM-30191: No list items defined for required poplist.
    or
    FRM-32082: Invalid value for given item type.
    List EMPNO
    Item: EMPNO
    Block: EMP
    Form: MODULE5
    FRM-30085: Unable to adjust form for output.
    then according to some docs, i tried the the following for the trigger
    when-new-form-instance
    declare
         rg_name varchar2(40) := 'emp_rec';
         status number;
         groupid recordgroup;
         it_id item;
    begin
         it_id := Find_Item('empno');
         groupid := create_group_from_query(rg_name, 'select empno from emp');
         status := populate_group(groupid);
         populate_list(it_id, groupid);
    end;
    but yet didnt work... :(
    so how the heck do i get values fetched from the database table into the list item?

    for list items you need to values in the record group, one is the shown value and one is the returned value.
    Check out the online help for the populate_list built-in.
    You'll need something like select ename,ename from emp as the record group query.

  • How to get value in a web page automatically  and sava output in database

    how to get value this table output is
    row 1, cell 1
    row 1, cell 2
    row 2, cell 1
    row 2, cell 2
    <table border="1">
    <tr>
    <td>row 1, cell 1</td>
    <td>row 1, cell 2</td>
    </tr>
    <tr>
    <td>row 2, cell 1</td>
    <td>row 2, cell 2</td>
    </tr>
    </table>

    Note: This thread was originally posted in the [Java Technologies for Web Services|http://forums.sun.com/forum.jspa?forumID=331] forum, but moved to this forum for closer topic alignment.

  • How to get value in function insert table test ?

    Hi
    I use function insert table test in order to get value in table for use in code page but i don't know how to get value in table.If somebody have any idea.Please give me some advice.
    Thank you,
    Waruja

    You will need to grab the contents with VBA
    Table test is user interface only.
    This thread may help
    http://qazone.empirix.com/thread.jspa?threadID=748&tstart=0

  • How to get value of URL parameter

    Hi,
    If an ABAP Web Dynpro URL looks like this: http://<server>:<port>/sap/bc/webdynpro/sap/zny_test1?sap-client=100&sap-language=EN, how to get value of the URL parameter “sap-client” at runtime in the application?
    Thanks,
    Nancy

    The framework currently strips all the framework specific params.
    Perhaps the will be made available in a future release.  Thomas, any comments ?
    However, I dont understand the requriement to know the sap-client URL value.
    If your code is running, a user has successfully connected to system a therefore he has a session open and this session is associated with exactly 1 client at any point in time.
    See SYSTEM VARAIBLE   SY-MANDT.
    this represents the client in which the users session is running and negates the need to see
    sap-client URL value.
    regards
    Phil.

  • How to get value of html combo box (i.e select) in jsp?

    Hello,
    I was just wondering how to get value of html combo box in jsp page. My code for combo box is:
    <select name="combo" size="1">
    <%
    List<Project> projects = mgr.getProjects();
    for(Project project : projects){
    %>
    <option value="<%= project.getId()%>"><%= project.getName()%></option>
    <%
    %>
    </select>
    I thought combo.value might give me the value, but it throws exception.
    Any help is appreciated.
    Thanks.

    The combo does not exists in Java, but only in HTML. You have to submit the form containing the combo and then use request.getParameter("combo") to get it's value ;-)

  • How to get list of modified repository objects in SPAU

    Hi,
    While applying Support pack for HR (SAP ERP 6.0) I get SPAU prompt with message:
    "The system detected that 10 of the repository objects in the Support Packages have been modified in
    your system . Check whether you want to retain or restore these changes you have made. Fore more
    info about performing modification adjustment see modification adjustment help..."
    Now as I call SPAU i get the screen with following options:
    Correction in SAP Note
    With modification Assistant
    Without  modification Assistant
    etc..
    Can someone guide me How to get list of modified repository objects in SPAU.
    Thanks & Regards
    Vishal

    Hi,
    In SPAU you will get with modification assistence. just expand the subtree, and follw standard process .
    This is to retain the enhancement. If there are any data dictionary related correction go to SPDD.
    Regards
    Rahul

  • How to get Value of tree node without Reload Page

    hi,
    i worked with apex 4.2 and i created Tree and tabular form to retrieve the date according the value of tree select node the code of tree something like this
    select case when connect_by_isleaf = 1 then 0
    when level = 1 then 1
    else -1
    end as status,
    level,
    "ENAME" as title,
    null as icon,
    "EMPNO" as value,
    null as tooltip,
    'f?p=36648:34:5234984107903::::P40_SELECTED_NODE:'||empno as link
    from "DEPT"."EMP"
    start with "MGR" is null
    connect by prior "EMPNO" = "MGR"
    order siblings by "ENAME
    and i put Selected Node Page Item: P40_SELECTED_NODE . the tree worked good and retrieve the data into tabular form according to tree node value
    my Question :
    1- i want to retrieve the data without submit the page where each time i select value from tree make page reload to update the tabular form with new value ,there is any way to pass the value of tree node to P40_SELECTED_NODE item and refresh tabular form without page reload .
    2- i want when selected from tree run page process according to value of tree node i tray to create Dynamic action with *(jquery selector : div.tree li>a)* but the Value of node incorrect.
    Regards
    Ahmed;

    look at this link
    Re: How to get Value of tree node without Reload Page ..!

  • How to get Value of a item of first record when current record is second

    How to get Value of a item of first record when current record is second in Form6i ?
    get_item_instance_property dose not allow to get value.

    Gerd,
    You're right, there are several other triggers that must be coded, but I was responding to Steve's statement about Inserting or deleting records from the multi-record block. For the record, I use the following to manage a Record Group:
    * When-New-Block-Instance - Initialize the RG
    * block Post-Query - populate the RG
    * When-Create-Record - add new record to RG
    * When-Remove-Record - remove record from RG
    * block When-New-Item-Instance - capture previous value of the item or row
    * When-Validate-Item - Item specific Insert, Update, Delete of values in the RG
    There are a few other places as well, but these are the minimum. It might seem like a lot of code, but then again, I don't use this solution for every multi-line block. Like all tools, you use the right tool for the job. :-)
    Craig...

  • How to get event when any library object added to indesign doc?

    I want to do some operation when any library object is added to doc. So please tell me how to get event when any library object is added to the doc. better provide some code snippet.

    Daves61,
    I need to clarify what kind of event you're interested in.
    1. When you click once on page/spead widget in the Pages panel and only widget becomes selected. The layout window remains unchanged. OR
    2. When you doubleclick on page/spread widget the selected master spread appears in the layout window.
    In the first case you work with Pages panel.
    Have a look to file PageTransitionsPanelObserver.cpp from SDK. 
    PageTransitionsPanelObserver::LazyUpdate()
    In the second case you work with Layout window.

Maybe you are looking for