-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb12d2b
commit 2cbcb3b
Showing
13 changed files
with
607 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright © 2022 Алексей Каленчуков | ||
* GitHub: https://github.com/kalenchukov | ||
* E-mail: mailto:[email protected] | ||
*/ | ||
|
||
package dev.kalenchukov.morsecode; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Интерфейс для реализации класса кодировщика / декодировщика азбуки Морзе. | ||
*/ | ||
public interface Codable | ||
{ | ||
/** | ||
* Кодирует символы в сигналы. | ||
* | ||
* @param text Текст. | ||
* @return Закодированный текст. | ||
*/ | ||
@NotNull | ||
String encode(@NotNull String text); | ||
|
||
/** | ||
* Декодирует сигналы в символы. | ||
* | ||
* @param code Код. | ||
* @return Декодированный текст. | ||
*/ | ||
@NotNull | ||
String decode(@NotNull String code); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright © 2022 Алексей Каленчуков | ||
* GitHub: https://github.com/kalenchukov | ||
* E-mail: mailto:[email protected] | ||
*/ | ||
|
||
package dev.kalenchukov.morsecode; |
69 changes: 69 additions & 0 deletions
69
src/main/java/dev/kalenchukov/morsecode/schemes/EnglishScheme.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright © 2022 Алексей Каленчуков | ||
* GitHub: https://github.com/kalenchukov | ||
* E-mail: mailto:[email protected] | ||
*/ | ||
|
||
package dev.kalenchukov.morsecode.schemes; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Unmodifiable; | ||
|
||
import java.util.Collections; | ||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Класс схемы сопоставления букв английского алфавита и сигналов.<br> | ||
* Схема соответствует рекомендации МСЭ-R M.1677-1. | ||
*/ | ||
public class EnglishScheme implements Schematic | ||
{ | ||
/** | ||
* Схема сопоставления символов с сигналами. | ||
*/ | ||
@NotNull | ||
private static final Map<@NotNull String, @NotNull List<@NotNull String>> SCHEME = new LinkedHashMap<>(); | ||
|
||
static | ||
{ | ||
SCHEME.put("A", List.of(".-")); | ||
SCHEME.put("B", List.of("-...")); | ||
SCHEME.put("C", List.of("-.-.")); | ||
SCHEME.put("D", List.of("-..")); | ||
SCHEME.put("E", List.of(".", "..-..")); | ||
SCHEME.put("F", List.of("..-.")); | ||
SCHEME.put("G", List.of("--.")); | ||
SCHEME.put("H", List.of("....")); | ||
SCHEME.put("I", List.of("..")); | ||
SCHEME.put("J", List.of(".---")); | ||
SCHEME.put("K", List.of("-.-")); | ||
SCHEME.put("L", List.of(".-..")); | ||
SCHEME.put("M", List.of("--")); | ||
SCHEME.put("N", List.of("-.")); | ||
SCHEME.put("O", List.of("---")); | ||
SCHEME.put("P", List.of(".--.")); | ||
SCHEME.put("Q", List.of("--.-")); | ||
SCHEME.put("R", List.of(".-.")); | ||
SCHEME.put("S", List.of("...")); | ||
SCHEME.put("T", List.of("-")); | ||
SCHEME.put("U", List.of("..-")); | ||
SCHEME.put("V", List.of("...-")); | ||
SCHEME.put("W", List.of(".--")); | ||
SCHEME.put("X", List.of("-..-")); | ||
SCHEME.put("Y", List.of("-.--")); | ||
SCHEME.put("Z", List.of("--..")); | ||
} | ||
|
||
/** | ||
* @see Schematic#getScheme() | ||
*/ | ||
@Unmodifiable | ||
@NotNull | ||
@Override | ||
public Map<@NotNull String, @NotNull List<@NotNull String>> getScheme() | ||
{ | ||
return Collections.unmodifiableMap(EnglishScheme.SCHEME); | ||
} | ||
} |
Oops, something went wrong.