### opdracht 1 ### ### Student.java ### public class Student { ... Double studentCijfer; ... public Student(..., Double cijferStud){ ... this.studentCijfer = cijferStud; ... } ... public Double getStudentCijfer() { return studentCijfer; } ... } ### MainActivity.java ### @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ... Student s = new Student("Jean Luc", 23, 5.3); String varMessage1 = Double.toString(s.studentCijfer); ... }
Download hier het bestand.
### opdracht 2 ### ### activity_main.xml ### <androidx.constraintlayout.widget...> ... <EditText android:id="@+id/editTextStudentNaam" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="10" android:inputType="textPersonName" android:text="Naam" tools:layout_editor_absoluteX="7dp" tools:layout_editor_absoluteY="6dp" /> <EditText android:id="@+id/editTextStudentNummer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="44dp" android:ems="10" android:inputType="textPersonName" android:text="Nummer" app:layout_constraintTop_toBottomOf="@+id/editTextStudentNaam" tools:layout_editor_absoluteX="7dp" /> <EditText android:id="@+id/editTextStudentCijfer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="44dp" android:ems="10" android:inputType="textPersonName" android:text="Cijfer" app:layout_constraintTop_toBottomOf="@+id/editTextStudentNummer" tools:layout_editor_absoluteX="7dp" /> <Button android:id="@+id/button" android:layout_width="165dp" android:layout_height="40dp" android:layout_marginStart="32dp" android:text="Button" app:layout_constraintStart_toEndOf="@+id/editTextStudentNaam" tools:layout_editor_absoluteY="6dp" /> ... </androidx.constraintlayout.widget.ConstraintLayout>
Download hier het bestand.
### opdracht 3 ### ### activity_main.xml ### <androidx.constraintlayout.widget...> <Button ... android:onClick="initStudent" .../> </androidx.constraintlayout.widget.ConstraintLayout> ### MainActivity.java ### public class MainActivity extends AppCompatActivity { ... public void initStudent (View view) { EditText studentNaam = (EditText)findViewById(R.id.editTextStudentNaam); EditText studentNummer = (EditText)findViewById(R.id.editTextStudentNummer); EditText studentCijfer = (EditText)findViewById(R.id.editTextStudentCijfer); String Naam = studentNaam.getText().toString(); int Nummer = Integer.parseInt(studentNummer.getText().toString()); Double Cijfer = Double.parseDouble(studentCijfer.getText().toString()); Student s = new Student(Naam,Nummer,Cijfer); String varMessage1 = Double.toString(s.getStudentCijfer()); TextView myTextView = (TextView)findViewById(R.id.textView1); myTextView.setText(varMessage1); } ... }
Download hier het bestand.
### opdracht 4 ### ### Student.java ### public class Student { ... public String getUitslag(){ if (studentCijfer >= 5.5) { return "Geslaagd"; } else { return "Gezakt"; } } ... } ### MainActivity.java ### public class MainActivity extends AppCompatActivity { ... public void initStudent (View view) { ... String varMessage1 = s.getUitslag(); ... } ... }
Download hier het bestand.