From da1f304c02a09ecb72bc16b85c5e14c808b1821c Mon Sep 17 00:00:00 2001 From: turtel Date: Fri, 16 Feb 2024 22:45:10 +0100 Subject: [PATCH] first commit --- .gitignore | 1 + Cargo.lock | 7 ++++++ Cargo.toml | 8 ++++++ src/main.rs | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..a2473c5 --- /dev/null +++ b/Cargo.lock @@ -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" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..634196a --- /dev/null +++ b/Cargo.toml @@ -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] diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..6eea0d4 --- /dev/null +++ b/src/main.rs @@ -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); + } + + +} \ No newline at end of file