# Интерфейсы

Создадим интерфейс `myInterface` у которого будет 2 метода `send` и `sum`

## **Пример**

```java
public interface myInterface{
    public send() as void;
    public sum(a as int, b as int) as int;
}
```

Внесём класс `myClass`

## **Пример**

```java
public class myClass{
}
```

Чтобы подключить наш интерфейс, необходимо написать следующее:

## **Пример**

```java
public class myClass {
    public implements myInterface {

    }
}
```

Теперь, подключив интерфейс, пишем в теле `myInterface` методы, которые заявленные ранее в `myInterface`.

## **Пример**

```java
public class myClass {
    public implements myInterface {
        public send() as void{
                
        }
        public sum(a as int, b as int) as int{
            return 0;
        }
    }
}
```

В методе `send` мы можем написать подобное - `println(sum(1, 2) as string)`.

## **Пример**

```java
public send() as void{
    println(sum(1, 2) as string);
}
```

При вызове данного метода нам вернётся `0`, далее исправим это! Добавим элемент сложения.

## **Пример**

```java
public sum(a as int, b as int) as int{
    return a + b;
}
```

Больше ошибок не будет. Можем вызвать метод `send`

## **Пример**

```java
new myClass().send();
```

Вы можете подключать неограниченное число различных интерфейсов!

## **Полный Код**

```java
public interface myInterface {
    public send() as void;
    public sum(a as int, b as int) as int;
}

public class myClass {
    public implements myInterface {
        public send() as void{
            println(sum(1, 2) as string);
        }
        public sum(a as int, b as int) as int{
            return a + b;
        }
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.aegis-mine.ru/modifications/sozdanie-kontenta/crafttweaker/minecraft-1.19.2/interfeisy.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
