android4.2

01### opdracht 1 ###
02 
03### Student.java ###
04 
05public class Student {
06 
07    ...
08    Double studentCijfer;
09    ...
10 
11    public Student(..., Double cijferStud){
12        ...
13        this.studentCijfer = cijferStud;
14        ...
15    }
16 
17    ...
18 
19    public Double getStudentCijfer() {
20        return studentCijfer;
21    }
22 
23    ...
24 
25}
26 
27### MainActivity.java ###
28 
29@Override
30protected void onCreate(Bundle savedInstanceState) {
31    super.onCreate(savedInstanceState);
32    setContentView(R.layout.activity_main);
33 
34    ...
35 
36    Student s = new Student("Jean Luc", 23, 5.3);
37 
38    String varMessage1 = Double.toString(s.studentCijfer);
39     
40    ...
41 
42}

Download hier het bestand.
01### opdracht 2 ###
02 
03### activity_main.xml ###
04 
05<androidx.constraintlayout.widget...>
06 
07    ...
08 
09    <EditText
10        android:id="@+id/editTextStudentNaam"
11        android:layout_width="wrap_content"
12        android:layout_height="wrap_content"
13        android:ems="10"
14        android:inputType="textPersonName"
15        android:text="Naam"
16        tools:layout_editor_absoluteX="7dp"
17        tools:layout_editor_absoluteY="6dp" />
18 
19    <EditText
20        android:id="@+id/editTextStudentNummer"
21        android:layout_width="wrap_content"
22        android:layout_height="wrap_content"
23        android:layout_marginTop="44dp"
24        android:ems="10"
25        android:inputType="textPersonName"
26        android:text="Nummer"
27        app:layout_constraintTop_toBottomOf="@+id/editTextStudentNaam"
28        tools:layout_editor_absoluteX="7dp" />
29 
30    <EditText
31        android:id="@+id/editTextStudentCijfer"
32        android:layout_width="wrap_content"
33        android:layout_height="wrap_content"
34        android:layout_marginTop="44dp"
35        android:ems="10"
36        android:inputType="textPersonName"
37        android:text="Cijfer"
38        app:layout_constraintTop_toBottomOf="@+id/editTextStudentNummer"
39        tools:layout_editor_absoluteX="7dp" />
40 
41    <Button
42        android:id="@+id/button"
43        android:layout_width="165dp"
44        android:layout_height="40dp"
45        android:layout_marginStart="32dp"
46        android:text="Button"
47        app:layout_constraintStart_toEndOf="@+id/editTextStudentNaam"
48        tools:layout_editor_absoluteY="6dp" />
49 
50    ...
51 
52</androidx.constraintlayout.widget.ConstraintLayout>

Download hier het bestand.
01### opdracht 3 ###
02 
03### activity_main.xml ###
04 
05 
06<androidx.constraintlayout.widget...>
07 
08    <Button
09        ...
10        android:onClick="initStudent"
11        .../>
12 
13</androidx.constraintlayout.widget.ConstraintLayout>
14 
15### MainActivity.java ###
16 
17public class MainActivity extends AppCompatActivity {
18 
19    ...
20 
21    public void initStudent (View view) {
22 
23        EditText studentNaam = (EditText)findViewById(R.id.editTextStudentNaam);
24        EditText studentNummer = (EditText)findViewById(R.id.editTextStudentNummer);
25        EditText studentCijfer = (EditText)findViewById(R.id.editTextStudentCijfer);
26 
27        String Naam = studentNaam.getText().toString();
28        int Nummer = Integer.parseInt(studentNummer.getText().toString());
29        Double Cijfer = Double.parseDouble(studentCijfer.getText().toString());
30 
31        Student s = new Student(Naam,Nummer,Cijfer);
32 
33        String varMessage1 = Double.toString(s.getStudentCijfer());
34        TextView myTextView = (TextView)findViewById(R.id.textView1);
35        myTextView.setText(varMessage1);
36         
37    }
38 
39    ...
40     
41}

Download hier het bestand.
01### opdracht 4 ###
02 
03### Student.java ###
04 
05 
06public class Student {
07 
08    ...
09 
10    public String getUitslag(){
11 
12        if (studentCijfer >= 5.5) {
13            return "Geslaagd";
14        } else {
15            return "Gezakt";
16        }
17 
18    }
19 
20    ...
21 
22}
23 
24### MainActivity.java ###
25 
26public class MainActivity extends AppCompatActivity {
27 
28    ...
29 
30    public void initStudent (View view) {
31 
32        ...
33 
34        String varMessage1 = s.getUitslag();
35 
36        ...
37    }
38 
39    ...
40 
41}

Download hier het bestand.