Commit ea122820 authored by s9_saleni_s's avatar s9_saleni_s
Browse files

deleted Auto class and simplified code

parent f939b5a8
Pipeline #1770 failed with stages
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));
}
}
public class Main {
public static void main(String[] args) {
Auto car = new Auto("VW", "Passat", 125, 1.9f);
System.out.println(car);
printName("Sandis");
}
public static void printName(String name) {
System.out.println("My name is " + name + "!");
}
}
import static org.junit.jupiter.api.Assertions.*;
class AutoTest {
@org.junit.jupiter.api.Test
void getMake() {
}
@org.junit.jupiter.api.Test
void getModel() {
}
@org.junit.jupiter.api.Test
void getPower() {
}
@org.junit.jupiter.api.Test
void getEngineCapacity() {
}
@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() {
}
@org.junit.jupiter.api.Test
void testToString() {
}
@org.junit.jupiter.api.Test
void calculateHorsePower() {
}
@org.junit.jupiter.api.Test
void calculateFuelConsuption() {
}
@org.junit.jupiter.api.Test
void brakeDistance() {
}
}
\ No newline at end of file
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class MainTest {
@Test
void printName() {
}
}
\ 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