Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 328dd52

Browse files
author
harunpetekkaya21
authored
Create Vehicle.java
1 parent ee7bc60 commit 328dd52

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

‎Inheritance/Vehicle.java‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package Inheritance.InheritanceChallenge;
2+
3+
public class Vehicle {
4+
private String name;
5+
private String size;
6+
7+
private int currentVelocity;
8+
private int currentDirection;
9+
10+
public Vehicle(String name, String size) {
11+
this.name = name;
12+
this.size = size;
13+
14+
this.currentVelocity=0;
15+
this.currentDirection=0;
16+
}
17+
18+
public void steer(int direction){
19+
this.currentDirection+=direction;
20+
System.out.println("Vehicle.steer() Steering at " + currentDirection + " degrees.");
21+
}
22+
23+
public void move(int velocity,int direction){
24+
currentVelocity=velocity;
25+
currentDirection=direction;
26+
System.out.println("Vehicle.move() Moving at " + currentVelocity + " in direction " + currentDirection);
27+
}
28+
public void stop(){
29+
this.currentVelocity=0;
30+
}
31+
32+
33+
34+
public String getName() {
35+
return name;
36+
}
37+
38+
39+
public String getSize() {
40+
return size;
41+
}
42+
43+
44+
public int getCurrentVelocity() {
45+
return currentVelocity;
46+
}
47+
48+
49+
public int getCurrentDirection() {
50+
return currentDirection;
51+
}
52+
53+
54+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /