Note that there are some explanatory texts on larger screens.

plurals
  1. POsetters and getters simple use?
    text
    copied!<p><strong>Question the SECOND PART</strong></p> <p>Thanks for the great help so far.. OK I've made progress but something still isn't right. My SpaceWarz class is as follows:</p> <pre><code>public class SpaceWarz { private boolean deePad; //access to this is restricted public boolean getDeePad() { return this.deePad; } public void setDeePad(boolean value) { this.deePad = value; } } </code></pre> <p>and it is happily sharing values with my Render class where the bulk of my code resides:</p> <pre><code>SpaceWarz sw = new SpaceWarz(); public void LoadGameSettings(){ sw.setDeePad(_dPad); // send value to SpaceWarz class _dPad = sw.getDeePad(); // get value from SpaceWarz class } </code></pre> <p>BUT values are NOT getting through from my onCreate method in the other class. The game data is loaded in the onCreate method and saved onDestroy so it's a problem if I can't then send that data on:</p> <pre><code> SpaceWarz sw = new SpaceWarz(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // SET SHARED DATA _dPad = true; // debug value to be removed. sw.setDeePad(_dPad); // SET SHARED DATA } </code></pre> <p>Any ideas how to put this right?</p> <p>&lt;--snip--></p> <p><strong>Question the FIRST PART</strong></p> <p>Need some very basic help with setters and getters. I'm trying to move data between a class containing my onCreate method and one containing my main code to load and save game settings when my app starts and stops. I was trying to use Bundles but It was suggested using setters and getters would be simpler.</p> <p>I've created a 3rd class called SpaceWarz:</p> <pre><code>package com.clockworkrobot.spacewarz; public class SpaceWarz { private boolean deePad; //access to this is restricted public boolean getDeePad() { return this.deePad; } public void setDeePad(boolean value) { this.deePad = value; } } </code></pre> <p>Am I setting that right and can anyone outline exactly how I set and get the value from my other classes as I'm not getting the syntax right causing a crash :(</p> <p>Thanks for taking a look.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload