-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.java
More file actions
33 lines (26 loc) · 937 Bytes
/
Copy pathProgram.java
File metadata and controls
33 lines (26 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
public class Program{
private int predkoscMax;
private String marka;
private String model;
private int predkosc;
public Program(String producent, String model, int predkoscMax) {
this.predkoscMax = predkoscMax > 0 ? predkoscMax : 0;
this.producent = producent != null ? producent : "nieznany";
this.model = model != null ? model : "model";
this.predkosc = 0;
}
public void przyspiesz(int i) {
int nowaPredkosc = this.predkosc + i;
this.predkosc = nowaPredkosc < this.predkoscMax ? nowaPredkosc : this.predkoscMax;
}
public void zwolnij(int i) {
int nowaPredkosc = this.predkosc - i;
this.predkosc = nowaPredkosc > 0 ? nowaPredkosc : 0;
}
public int aktualnaPredkosc() {
return this.predkosc;
}
public String toString() {
return this.marka + " " + this.model;
}
}