This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tamagotchi { | |
final String name; | |
final int age; | |
int hunger; | |
int happiness; | |
bool isAlive; | |
Tamagotchi({ | |
required this.name, | |
required this.age, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
print("MAUS") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
int zahl = 1; // Startwert der Zählvariablen | |
while (zahl <= 5) { | |
print(zahl); // Gibt die aktuelle Zahl aus | |
zahl++; // Erhöht die Zahl um eins | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
List<dynamic> z = [1, true, 2, 3.5, "vier", "Apfel"]; | |
// Hier iterieren wir über die Liste z und geben jedes Element aus. | |
for (var i in z) { | |
print(i); | |
} | |
// In dieser Schleife überprüfen wir den Typ jedes Elements. | |
// Wenn das Element ein Integer ist, wird es gedruckt. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
for (int i = 0; i < 5; i++) { | |
print(i); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
int temperatur = 15; // Setze hier deine Temperatur ein | |
// Schreibe hier deinen Code | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
int punktzahl = 75; | |
if (punktzahl >= 90) { | |
print("Ausgezeichnet!"); | |
} else if (punktzahl >= 80) { | |
print("Gut gemacht!"); | |
} else if (punktzahl >= 70) { | |
print("Bestanden."); | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
String passwort = "MeinPass"; // Setze hier dein Passwort ein | |
// Schreibe hier deinen Code für das if-else-Statement | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
int number = 10; // Du kannst diesen Wert ändern, um unterschiedliche Ergebnisse zu sehen. | |
if (number > 0) { | |
print("$number ist positiv."); | |
} else { | |
print("$number ist nicht positiv."); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
var message = 'Hallo, Dart!'; | |
print(message); // Gibt 'Hallo, Dart!' aus. 'message' ist jetzt vom Typ String. | |
// Folgende Zeile würde einen Fehler verursachen, weil 'message' als String inferiert wurde: | |
// message = 123; // Fehler: Eine Variable vom Typ String kann nicht als int zugewiesen werden. | |
var number = 10; | |
print(number); // Gibt '10' aus. 'number' ist jetzt vom Typ int. |
NewerOlder