Commit 4042965a authored by s9_saleni_s's avatar s9_saleni_s
Browse files

INIT

parents
Pipeline #1505 failed with stages
package vea.sdp2020;
public class Main {
public static void main(String[] args) {
// write your code here
}
}
package vea.sdp2020.model;
public class Auto {
private String make;
private String model;
private int power;
private float engineCapacity;
// Default constructor
public Auto() {
make = "Grabulis";
model = "Parastais";
power = 20;
engineCapacity = 0.001f;
}
// Constructor with arguments
public Auto(String mk, String md, int p, float ec) {
setMake(mk);
setModel(md);
setPower(p);
setEngineCapacity(ec);
}
// get methods
public String getMake() {
return make;
}
public String getModel() {
return model;
}
public int getPower() {
return power;
}
public float getEngineCapacity() {
return engineCapacity;
}
// set methods
public void setMake(String mk) {
make = mk;
}
public void setModel(String md) {
model = md;
}
public void setPower(int p) {
if (p>0)
power = p;
else
power = 20;
}
public void setEngineCapacity(float ec) {
if (ec>0)
engineCapacity = ec;
else
engineCapacity = 0.001f;
}
// toString method
public String toString() {
return make + " " + model + ", " + Integer.toString(power) + " kW, " + Float.toString(engineCapacity) + " m3.";
}
// Calculates horse power
public float calculateHorsePower() {
return power*1.36f;
}
// Calculate fuel consumption
public float calculateFuelConsuption() {
return (float) (Math.sqrt(engineCapacity)*6.7/100);
}
// Calculate brake distance
public float brakeDistance(String coefType) {
float coef = 0f;
if (coefType.equals("wet")) {
coef = 0.55f;
} else if(coefType.equals("dry")){
coef = 0.75f;
}
return (float) (25*25/(2*9.81*coef));
}
}
package vea.sdp2020.model;
import static org.junit.jupiter.api.Assertions.*;
class AutoTest {
@org.junit.jupiter.api.Test
void setMake() {
}
@org.junit.jupiter.api.Test
void setModel() {
}
@org.junit.jupiter.api.Test
void setPower() {
}
@org.junit.jupiter.api.Test
void setEngineCapacity() {
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment