Android programming Question

Howdy, I am a programmer who worked almost exclusively with C ++ / C # / vbs, and now I am entering the Android development world. I am faced with several problems that, it seems to me, do not find answers for / do not want to watch long training videos to find out, so I decided that I would ask here and get a quick answer.

I do not know if this is suitable for this, so I am open to any suggestions.

I need some custom data containers for my program, let's say I want the Achievement class, so I can have an array of them!

now in c # i would do something like

public class Achievment  
{
    bool locked;
    string achName;
    string achSubName;

    public Achievement(string name, string subname)
    {
        //ctor code goes here
    }
}

, , , . , Eclipse, , "Public type Achievement ?" .java ... -, ? . , java ... #!

, " ", . , ?

, , !

+3
4

( , - , ) Achievment.java.

+4

Achievement Achievement.java. , name :

...
public Achievement(String name, String subname)
{
    //ctor code goes here
}
...

Java String, String.

+5

java , ( Achievment.java).

+4

Create a file called Achievement.java in the source folder in the Java Eclipse project. You probably also want the class to exist in the package, so if your package name was "com.acme", then your Achievement.java file will exist in the following directory structure:

<project-folder>/src/com/acme/Achievement.java

Now, assuming that you have completed the above steps, you also need to make the following corrections to the code you sent:

package com.acme // NOTE: This maps to the directory structure

public class Achievement {
    private boolean locked;
    private String achName;
    private String achSubName;

    public Achievement(String name, String subname) {
        this.achName = name;
        this.achSubName = subname;
    }

    public boolean isLocked() {
        return this.locked;
    }

    public void setLocked(boolean locked) {
        this.locked = locked;
    }

    public String getName() {
        return this.achName;
    }

    public void setName(String name) {
        this.achName = name;
    }

    // etc ...
}
+1
source

Source: https://habr.com/ru/post/1761343/


All Articles