File tree 4 files changed +97
-0
lines changed
4 files changed +97
-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 ();
6
+
7
+ vehicle .setMake ("Porsche" );
8
+ vehicle .setModel ("911" );
9
+
10
+ vehicle .accelerate (30 );
11
+ vehicle .accelerate (30 );
12
+ vehicle .brake (20 );
13
+ vehicle .accelerate (40 );
14
+ }
15
+ }
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 void setMake (String make ) {
8
+ this .make = make ;
9
+ }
10
+
11
+ public void setModel (String model ) {
12
+ this .model = model ;
13
+ }
14
+
15
+ public String getMake () {
16
+ return make ;
17
+ }
18
+
19
+ public String getModel () {
20
+ return model ;
21
+ }
22
+
23
+ public double getSpeedInKmh () {
24
+ return speedInKmh ;
25
+ }
26
+
27
+ public void accelerate (int valueInKmh ) {
28
+ speedInKmh += valueInKmh ;
29
+ System .out .println (toString () + " beschleunigt auf " + speedInKmh + "km/h" );
30
+ }
31
+
32
+ public void brake (int valueInKmh ) {
33
+ speedInKmh -= valueInKmh ;
34
+ System .out .println (toString () + " bremst auf " + speedInKmh + "km/h ab" );
35
+ }
36
+
37
+ public String toString () {
38
+ return make + " " + model ;
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments