File tree Expand file tree Collapse file tree 4 files changed +91
-0
lines changed Expand file tree Collapse file tree 4 files changed +91
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : format and commit all java files
2
+
3
+ on :
4
+ workflow_dispatch :
5
+ push :
6
+ branches :
7
+ - ' exercises/**'
8
+ - ' solutions/**'
9
+
10
+ jobs :
11
+ formatting :
12
+ runs-on : ubuntu-latest
13
+ steps :
14
+ - uses : actions/checkout@v2
15
+ - uses : actions/setup-java@v3
16
+ with :
17
+ java-version : ' 17'
18
+ distribution : ' temurin'
19
+ - uses : axel-op/googlejavaformat-action@v3
Original file line number Diff line number Diff line change
1
+ # Compiled class file
2
+ * .class
3
+
4
+ # Log file
5
+ * .log
6
+
7
+ # BlueJ files
8
+ * .ctxt
9
+
10
+ # Mobile Tools for Java (J2ME)
11
+ .mtj.tmp /
12
+
13
+ # Package Files #
14
+ * .jar
15
+ * .war
16
+ * .nar
17
+ * .ear
18
+ * .zip
19
+ * .tar.gz
20
+ * .rar
21
+
22
+ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23
+ hs_err_pid *
Original file line number Diff line number Diff line change
1
+ public class Exercise {
2
+
3
+ public static void main (String [] args ) {
4
+
5
+ Vehicle vehicle = new Vehicle ("Porsche" , "911" );
6
+
7
+ vehicle .accelerate (30 );
8
+ vehicle .accelerate (30 );
9
+ vehicle .brake (20 );
10
+ vehicle .accelerate (40 );
11
+ }
12
+ }
Original file line number Diff line number Diff line change
1
+ public class Vehicle {
2
+
3
+ private String make ;
4
+ private String model ;
5
+ private double speedInKmh ;
6
+
7
+ public Vehicle (String make , String model ) {
8
+ this .make = make ;
9
+ this .model = model ;
10
+ }
11
+
12
+ public String getMake () {
13
+ return make ;
14
+ }
15
+
16
+ public String getModel () {
17
+ return model ;
18
+ }
19
+
20
+ public double getSpeedInKmh () {
21
+ return speedInKmh ;
22
+ }
23
+
24
+ public void accelerate (int valueInKmh ) {
25
+ speedInKmh += valueInKmh ;
26
+ System .out .println (toString () + " beschleunigt auf " + speedInKmh + "km/h" );
27
+ }
28
+
29
+ public void brake (int valueInKmh ) {
30
+ speedInKmh -= valueInKmh ;
31
+ System .out .println (toString () + " bremst auf " + speedInKmh + "km/h ab" );
32
+ }
33
+
34
+ public String toString () {
35
+ return make + " " + model ;
36
+ }
37
+ }
You can’t perform that action at this time.
0 commit comments