init refactoring exercise
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								dev_ops/gradle/uebung-01/.gradle/8.10.2/checksums/checksums.lock
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								dev_ops/gradle/uebung-01/.gradle/8.10.2/checksums/checksums.lock
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							@@ -0,0 +1,2 @@
 | 
			
		||||
#Tue Nov 05 16:02:41 CET 2024
 | 
			
		||||
gradle.version=8.10.2
 | 
			
		||||
							
								
								
									
										27
									
								
								dev_ops/gradle/uebung-01/build.gradle
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								dev_ops/gradle/uebung-01/build.gradle
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
// Define an extra property for the correct code
 | 
			
		||||
ext.correctCode = "1234"
 | 
			
		||||
 | 
			
		||||
// Task to save the code to a file
 | 
			
		||||
task save {
 | 
			
		||||
    doLast {
 | 
			
		||||
        def code = correctCode
 | 
			
		||||
        file("code.txt").text = code
 | 
			
		||||
        println "Code wurde gespeichert!"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Task to check the saved code, depends on the 'save' task
 | 
			
		||||
task check() {
 | 
			
		||||
    doLast {
 | 
			
		||||
        def code = file("code.txt").text.trim()
 | 
			
		||||
 | 
			
		||||
        if (code == correctCode)
 | 
			
		||||
            println "Ausgelesener Code ${code} ist korrekt."
 | 
			
		||||
        else
 | 
			
		||||
            throw new Exception("Fehler: Der Code ist inkorrekt.")
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
task unlock(dependsOn: check) {
 | 
			
		||||
    println "Das Schloss wurde geoeffnet."
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1
									
								
								dev_ops/gradle/uebung-01/code.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								dev_ops/gradle/uebung-01/code.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
1235
 | 
			
		||||
		Reference in New Issue
	
	Block a user