Merge branch 'main' of https://gitty.informatik.hs-mannheim.de/3003916/groovy-lecture
|
@ -0,0 +1 @@
|
||||||
|
.DS_Store
|
|
@ -1,3 +1,41 @@
|
||||||
|
### Enums
|
||||||
|
Enums sind gleich wie in Java
|
||||||
|
|
||||||
|
```Groovy
|
||||||
|
enum Day{
|
||||||
|
MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY
|
||||||
|
}
|
||||||
|
|
||||||
|
Day today = Day.MONDAY
|
||||||
|
```
|
||||||
|
|
||||||
|
Man kann in Enums zusätzlich noch Eigenschaften und Methoden einbauen
|
||||||
|
|
||||||
|
```Groovy
|
||||||
|
enum Day{
|
||||||
|
MONDAY("First Day of the Week"),
|
||||||
|
TUESDAY("Second Day of the Week),
|
||||||
|
//...
|
||||||
|
|
||||||
|
final String description
|
||||||
|
|
||||||
|
Day(String description){
|
||||||
|
this.description = description
|
||||||
|
}
|
||||||
|
|
||||||
|
String getDescription(){
|
||||||
|
return description
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Day today = Day.FRIDAY
|
||||||
|
def description = today.getDescription
|
||||||
|
println("Today is $today: $description")
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Zusätzlich dazu kann man auch Methoden überschreiben (z.B. toString()-Methode)
|
||||||
|
|
||||||
### Ranges
|
### Ranges
|
||||||
Ähnlich wie in Ruby, jedoch nicht gleich
|
Ähnlich wie in Ruby, jedoch nicht gleich
|
||||||
```Groovy
|
```Groovy
|
||||||
|
@ -109,3 +147,5 @@ Entfernen eines Elements:
|
||||||
```Groovy
|
```Groovy
|
||||||
mySet.remove(1)
|
mySet.remove(1)
|
||||||
println mySet // [2,3,4,5,6,7]
|
println mySet // [2,3,4,5,6,7]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
After Width: | Height: | Size: 89 KiB |
After Width: | Height: | Size: 144 KiB |
After Width: | Height: | Size: 83 KiB |
After Width: | Height: | Size: 57 KiB |
After Width: | Height: | Size: 78 KiB |
After Width: | Height: | Size: 89 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 93 KiB |
After Width: | Height: | Size: 180 KiB |
After Width: | Height: | Size: 161 KiB |
After Width: | Height: | Size: 103 KiB |
After Width: | Height: | Size: 134 KiB |
After Width: | Height: | Size: 106 KiB |
After Width: | Height: | Size: 86 KiB |
After Width: | Height: | Size: 103 KiB |
After Width: | Height: | Size: 126 KiB |
After Width: | Height: | Size: 169 KiB |
After Width: | Height: | Size: 68 KiB |
After Width: | Height: | Size: 144 KiB |
After Width: | Height: | Size: 109 KiB |