-
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.
- Loading branch information
1 parent
39add6c
commit 3b13318
Showing
8 changed files
with
74 additions
and
11 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 |
---|---|---|
@@ -1 +1,5 @@ | ||
package Objects; | ||
public class Bicycle extends Vehicle { | ||
public String Typename = "Bike"; | ||
public int wheels = 2, pedals = 2; | ||
} |
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
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,14 @@ | ||
package Objects; | ||
|
||
public class Friend { | ||
|
||
|
||
public String name; | ||
|
||
public static int numberOfFriends; | ||
|
||
public Friend(String name){ | ||
this.name=name; | ||
numberOfFriends++; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,16 @@ | ||
package Objects; | ||
|
||
public class Vehicle { | ||
|
||
// inheritance = the process where one class acquires, | ||
// the attributes and methods of another. | ||
public String Typename; | ||
public double speed; | ||
|
||
public void go(String Typename){ | ||
System.out.println("The "+Typename+" is moving"); | ||
} | ||
public void stop(String Typename){ | ||
System.out.println("The "+Typename+" is stopped"); | ||
} | ||
|
||
} |
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 files; | ||
import Objects.Bicycle; | ||
import Objects.Car; | ||
|
||
public class Inheritance { | ||
public static void main(String[] args) { | ||
run(); | ||
} | ||
public static void run() {Car car = new Car(); | ||
|
||
car.go(car.Typename); | ||
car.stop(car.Typename); | ||
|
||
Bicycle bike = new Bicycle(); | ||
|
||
bike.go(bike.Typename); | ||
bike.stop(bike.Typename); | ||
|
||
System.out.println(car.door); | ||
System.out.println(bike.pedals); | ||
} | ||
} |
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 files; | ||
|
||
import Objects.Friend; | ||
|
||
public class StaticKeyWord { | ||
// static = modifier. A single copy of a variable/method is created and shared. | ||
// The class "owns" the static member | ||
|
||
public static void main(String[] args) { | ||
run(); | ||
} | ||
public static void run() { | ||
//Static key world can be used in function oriented programing. Usually it's not so used in OOP | ||
Friend friend1 = new Friend("Sponegbob"); | ||
Friend friend2 = new Friend("Patrick"); | ||
Friend friend3 = new Friend("Patrick"); | ||
|
||
System.out.println(Friend.numberOfFriends); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.