-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inheritance and inheritance.homework packages
- Loading branch information
1 parent
4c63cde
commit d44fd2d
Showing
8 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
plugins { | ||
id 'java' | ||
} | ||
|
||
group = 'com.kodilla' | ||
version = '1.0-SNAPSHOT' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
testImplementation platform('org.junit:junit-bom:5.10.0') | ||
testImplementation 'org.junit.jupiter:junit-jupiter' | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} |
12 changes: 12 additions & 0 deletions
12
kodilla-basic-tests/src/main/java/com/kodilla/inheritance/Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.kodilla.inheritance; | ||
|
||
public class Application { | ||
public static void main(String[] args) { | ||
Car car = new Car(4, 5); | ||
car.turnOnLights(); | ||
|
||
Convertible convertible = new Convertible(4, 2); | ||
convertible.turnOnLights(); | ||
System.out.println(convertible.getSeats()); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
kodilla-basic-tests/src/main/java/com/kodilla/inheritance/Car.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.kodilla.inheritance; | ||
|
||
public class Car { | ||
private int wheels; | ||
private int seats; | ||
|
||
public Car(int wheels, int seats) { | ||
this.wheels = wheels; | ||
this.seats = seats; | ||
} | ||
|
||
public int getWheels() { | ||
return wheels; | ||
} | ||
|
||
public int getSeats() { | ||
return seats; | ||
} | ||
|
||
public void turnOnLights() { | ||
System.out.println("Lights were turned on"); | ||
} | ||
|
||
public void openDoors() { | ||
System.out.println("Opening 4 doors"); | ||
} | ||
|
||
public void displayNumberOfSeats() { | ||
System.out.println("Number of seats: " + seats); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
kodilla-basic-tests/src/main/java/com/kodilla/inheritance/Convertible.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.kodilla.inheritance; | ||
|
||
public class Convertible extends Car { | ||
|
||
public Convertible(int wheels, int seats) { | ||
super(wheels, seats); | ||
System.out.println("Convertible constructor"); | ||
} | ||
|
||
public void openRoof() { | ||
System.out.println("Opening roof..."); | ||
} | ||
|
||
public void closeRoof() { | ||
System.out.println("Closing roof..."); | ||
} | ||
|
||
@Override | ||
public void openDoors() { | ||
System.out.println("Opening 2 doors"); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
kodilla-basic-tests/src/main/java/com/kodilla/inheritance/homework/Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.kodilla.inheritance.homework; | ||
|
||
public class Application { | ||
public static void main(String[] args) { | ||
OperatingSystem operatingSystem = new OperatingSystem(2005); | ||
operatingSystem.turnOn(); | ||
operatingSystem.turnOff(); | ||
operatingSystem.displayReleaseYear(); | ||
|
||
Windows10 win10 = new Windows10(); | ||
win10.turnOn(); | ||
win10.turnOff(); | ||
win10.displayReleaseYear(); | ||
|
||
Windows11 win11 = new Windows11(); | ||
win11.turnOn(); | ||
win11.turnOff(); | ||
win11.displayReleaseYear(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
kodilla-basic-tests/src/main/java/com/kodilla/inheritance/homework/OperatingSystem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.kodilla.inheritance.homework; | ||
|
||
public class OperatingSystem { | ||
private int releaseYear; | ||
|
||
public OperatingSystem(int releaseYear) { | ||
this.releaseYear = releaseYear; | ||
} | ||
|
||
public void turnOn() { | ||
System.out.println("turning system on..."); | ||
} | ||
|
||
public void turnOff() { | ||
System.out.println("turning system off..."); | ||
} | ||
|
||
public void displayReleaseYear() { | ||
System.out.println("this system's release year: " + releaseYear); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
kodilla-basic-tests/src/main/java/com/kodilla/inheritance/homework/Windows10.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.kodilla.inheritance.homework; | ||
|
||
public class Windows10 extends OperatingSystem { | ||
public Windows10() { | ||
super(2015); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
kodilla-basic-tests/src/main/java/com/kodilla/inheritance/homework/Windows11.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.kodilla.inheritance.homework; | ||
|
||
public class Windows11 extends OperatingSystem { | ||
public Windows11() { | ||
super(2021); | ||
} | ||
} |