Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .gitignore
Binary file not shown.
75 changes: 71 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>praktikum</artifactId>
<groupId>praktikum</groupId>
<artifactId>Task_1</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

</project>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.12.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>11</source>
<target>11</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
<configuration>
<excludes>
<exclude>praktikum/Database*</exclude>
<exclude>praktikum/Praktikum*</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>

</project>
70 changes: 35 additions & 35 deletions src/main/java/praktikum/Database.java
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
package praktikum;
import java.util.ArrayList;
import java.util.List;
/**
* Класс с методами по работе с базой данных.
*/
public class Database {
private final List<Bun> buns = new ArrayList<>();
private final List<Ingredient> ingredients = new ArrayList<>();
public Database() {
buns.add(new Bun("black bun", 100));
buns.add(new Bun("white bun", 200));
buns.add(new Bun("red bun", 300));
ingredients.add(new Ingredient(IngredientType.SAUCE, "hot sauce", 100));
ingredients.add(new Ingredient(IngredientType.SAUCE, "sour cream", 200));
ingredients.add(new Ingredient(IngredientType.SAUCE, "chili sauce", 300));
ingredients.add(new Ingredient(IngredientType.FILLING, "cutlet", 100));
ingredients.add(new Ingredient(IngredientType.FILLING, "dinosaur", 200));
ingredients.add(new Ingredient(IngredientType.FILLING, "sausage", 300));
}
public List<Bun> availableBuns() {
return buns;
}
public List<Ingredient> availableIngredients() {
return ingredients;
}
package praktikum;

import java.util.ArrayList;
import java.util.List;

/**
* Класс с методами по работе с базой данных.
*/
public class Database {

private final List<Bun> buns = new ArrayList<>();
private final List<Ingredient> ingredients = new ArrayList<>();

public Database() {
buns.add(new Bun("black bun", 100));
buns.add(new Bun("white bun", 200));
buns.add(new Bun("red bun", 300));

ingredients.add(new Ingredient(IngredientType.SAUCE, "hot sauce", 100));
ingredients.add(new Ingredient(IngredientType.SAUCE, "sour cream", 200));
ingredients.add(new Ingredient(IngredientType.SAUCE, "chili sauce", 300));

ingredients.add(new Ingredient(IngredientType.FILLING, "cutlet", 100));
ingredients.add(new Ingredient(IngredientType.FILLING, "dinosaur", 200));
ingredients.add(new Ingredient(IngredientType.FILLING, "sausage", 300));
}

public List<Bun> availableBuns() {
return buns;
}

public List<Ingredient> availableIngredients() {
return ingredients;
}

}
74 changes: 37 additions & 37 deletions src/main/java/praktikum/Praktikum.java
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
package praktikum;
import java.util.List;
public class Praktikum {
public static void main(String[] args) {
// Инициализируем базу данных
Database database = new Database();
// Создадим новый бургер
Burger burger = new Burger();
// Считаем список доступных булок из базы данных
List<Bun> buns = database.availableBuns();
// Считаем список доступных ингредиентов из базы данных
List<Ingredient> ingredients = database.availableIngredients();
// Соберём бургер
burger.setBuns(buns.get(0));
burger.addIngredient(ingredients.get(1));
burger.addIngredient(ingredients.get(4));
burger.addIngredient(ingredients.get(3));
burger.addIngredient(ingredients.get(5));
// Переместим слой с ингредиентом
burger.moveIngredient(2, 1);
// Удалим ингредиент
burger.removeIngredient(3);
// Распечатаем рецепт бургера
System.out.println(burger.getReceipt());
}
package praktikum;

import java.util.List;

public class Praktikum {

public static void main(String[] args) {
// Инициализируем базу данных
Database database = new Database();

// Создадим новый бургер
Burger burger = new Burger();

// Считаем список доступных булок из базы данных
List<Bun> buns = database.availableBuns();

// Считаем список доступных ингредиентов из базы данных
List<Ingredient> ingredients = database.availableIngredients();

// Соберём бургер
burger.setBuns(buns.get(0));

burger.addIngredient(ingredients.get(1));
burger.addIngredient(ingredients.get(4));
burger.addIngredient(ingredients.get(3));
burger.addIngredient(ingredients.get(5));

// Переместим слой с ингредиентом
burger.moveIngredient(2, 1);

// Удалим ингредиент
burger.removeIngredient(3);

// Распечатаем рецепт бургера
System.out.println(burger.getReceipt());
}

}
41 changes: 41 additions & 0 deletions src/test/java/praktikum/BunTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package praktikum;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import static org.junit.Assert.assertEquals;

@RunWith(Parameterized.class)
public class BunTest {

private final String name;
private final float price;

public BunTest(String name, float price) {
this.name = name;
this.price = price;
}

@Parameterized.Parameters
public static Object[][] getBunData() {
return new Object[][]{
{"black bun", 100f},
{"white bun", 200f}
};
}

@Test
public void getNameShouldReturnCorrectName() {
Bun bun = new Bun(name, price);

assertEquals(name, bun.getName());
}

@Test
public void getPriceShouldReturnCorrectPrice() {
Bun bun = new Bun(name, price);

assertEquals(price, bun.getPrice(), 0);
}
}
Loading