first commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/target
|
||||
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "morse_translator"
|
||||
version = "0.1.0"
|
||||
8
Cargo.toml
Normal file
8
Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "morse_translator"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
72
src/main.rs
Normal file
72
src/main.rs
Normal file
@@ -0,0 +1,72 @@
|
||||
use std::io;
|
||||
|
||||
fn main() {
|
||||
struct MorseAlphabet {
|
||||
A: String,
|
||||
B: String,
|
||||
C: String,
|
||||
D: String,
|
||||
E: String,
|
||||
F: String,
|
||||
G: String,
|
||||
H: String,
|
||||
I: String,
|
||||
J: String,
|
||||
K: String,
|
||||
L: String,
|
||||
M: String,
|
||||
N: String,
|
||||
O: String,
|
||||
P: String,
|
||||
Q: String,
|
||||
R: String,
|
||||
S: String,
|
||||
T: String,
|
||||
U: String,
|
||||
V: String,
|
||||
W: String,
|
||||
X: String,
|
||||
Y: String,
|
||||
Z: String,
|
||||
};
|
||||
|
||||
let Code_morse = MorseAlphabet {
|
||||
A: ".—".to_string(),
|
||||
B: "-...".to_string(),
|
||||
C: "-.-.".to_string(),
|
||||
D: "-..".to_string(),
|
||||
E: ".".to_string(),
|
||||
F: "..-.".to_string(),
|
||||
G: "--.".to_string(),
|
||||
H: "....".to_string(),
|
||||
I: "..".to_string(),
|
||||
J: ".---".to_string(),
|
||||
K: "-.-".to_string(),
|
||||
L: ".-..".to_string(),
|
||||
M: "--".to_string(),
|
||||
N: "-.".to_string(),
|
||||
O: "---".to_string(),
|
||||
P: ".--.".to_string(),
|
||||
Q: "--.-".to_string(),
|
||||
R: ".-.".to_string(),
|
||||
S: "...".to_string(),
|
||||
T: "-".to_string(),
|
||||
U: "..-".to_string(),
|
||||
V: "...-".to_string(),
|
||||
W: ".--".to_string(),
|
||||
X: "-..-".to_string(),
|
||||
Y: "-.--".to_string(),
|
||||
Z: "--..".to_string()
|
||||
};
|
||||
|
||||
println!("Enter a word");
|
||||
//get user input
|
||||
let mut input = String::new();
|
||||
io::stdin().read_line(&mut input).expect("Wrong input you idiot");
|
||||
|
||||
for _letter in input.chars() {
|
||||
print!("{}", Code_morse.A);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user