11_ifPrint
Code-Dateien
| Dateiname | Aktion |
|---|---|
| CODECode_ClassRoom.zip | Download |
| CODECode_Fenster.zip | Download |
| CODECode_Student.zip | Download |
| CODECode_Urlaub.zip | Download |
PDF-Dokumente
| Dateiname | Aktion |
|---|---|
| PDFFolie_ClassRoom.pdf | Öffnen |
| PDFFolie_Student.pdf | Öffnen |
| PDFFolie_Urlaub.pdf | Öffnen |
| PDFUebung_Computer.pdf | Öffnen |
| PDFUebung_Labor.pdf | Öffnen |
| PDFUebung_Wohnung.pdf | Öffnen |
Videos
| Dateiname | Aktion |
|---|---|
| VIDEOVideo_ClassRoom_E | Abspielen |
| VIDEOVideo_Fenster_D | Abspielen |
| VIDEOVideo_Student_D | Abspielen |
| VIDEOVideo_Urlaub_D | Abspielen |
Lernmaterialien
if Print
Syntax
Syntax der if Abfrage:
if (condition)
{
command;
command;
}
else
{
commad;
command;
}Eine if-Abfrage (oder if-Anweisung)
ist ein Kontrollfluss-Konstrukt in Programmiersprachen
wie Java, C, C++, Python usw.
Sie ermöglicht es, dass ein Programm bestimmte Anweisungen nur
dann ausführt, wenn eine Bedingung condition wahr
(true) ist.
Weiters ermöglicht sie, dass andere Anweisungen nur dann
ausgeführt werden, wenn eine Bedingung condition falsch
(false) ist.
printMethode
Derzeit liefert die print Methode die Eigenschaft matura
als true bzw. false. Diese gilt auch bei der
Ausgabe durch printStudent.
Alex - 23 Jahre: trueMusterausgabe. Dabei kann ich als Anwender den Wert true nicht deuten.
/*
Print Methode
name - alter Jahre: hat Matura
Max - 29 Jahre: hat Matura
Susi - 22 Jahre: hat keine Matura
Werner - 21 Jahre: hat Matura
*/
public void printStudent()
{
if (matura == true)
{
System.out.println(name + " - " + alter + " Jahre: " + " hat Matura");
}
else
{
System.out.println(name + " - " + alter + " Jahre: " + " hat keine Matura");
}
}Alex - 14 Jahre: hat Matura
Susi - 22 Jahre: hat keine MaturaAusgabe nach der Implementierung.