Test aktualisiert

This commit is contained in:
dominik 2023-07-26 17:22:22 +00:00
parent 40a6ab6263
commit c7ec6c46d1

62
Test
View File

@ -1,34 +1,48 @@
void main() {
print('Hello, World!');
runApp(MyApp());
}
int factorial(int n) {
if (n == 0 || n == 1) {
return 1;
} else {
return n * factorial(n - 1);
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Color Changer'),
),
body: ColorChanger(),
),
);
}
}
void main() {
int number = 5;
int result = factorial(number);
print('The factorial of $number is $result.');
class ColorChanger extends StatefulWidget {
@override
_ColorChangerState createState() => _ColorChangerState();
}
int findMax(List<int> numbers) {
int max = numbers[0];
for (int i = 1; i < numbers.length; i++) {
if (numbers[i] > max) {
max = numbers[i];
}
}
return max;
}
class _ColorChangerState extends State<ColorChanger> {
Color _backgroundColor = Colors.white;
void main() {
List<int> numbers = [12, 56, 3, 78, 42, 9];
int maxNumber = findMax(numbers);
print('The maximum number in the list is $maxNumber.');
void changeBackgroundColor() {
setState(() {
_backgroundColor = Color(Random().nextInt(0xFFFFFFFF));
});
}
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => changeBackgroundColor(),
child: Container(
color: _backgroundColor,
child: Center(
child: Text(
'Tap to Change Color',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
),
),
);
}
}