Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
Morse
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
benjamin.godfrey
Morse
Commits
57fce6ea
Commit
57fce6ea
authored
Nov 21, 2017
by
m.baxter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Basic skeleton of the code.
parent
d31faef9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
9 deletions
+66
-9
Main.class
bin/MorseConverter/Main.class
+0
-0
Morse.class
bin/MorseConverter/Morse.class
+0
-0
Main.java
src/MorseConverter/Main.java
+9
-4
Morse.java
src/MorseConverter/Morse.java
+57
-5
No files found.
bin/MorseConverter/Main.class
View file @
57fce6ea
No preview for this file type
bin/MorseConverter/Morse.class
View file @
57fce6ea
No preview for this file type
src/MorseConverter/Main.java
View file @
57fce6ea
...
@@ -13,18 +13,23 @@ public class Main {
...
@@ -13,18 +13,23 @@ public class Main {
int
menuSelect
;
int
menuSelect
;
Scanner
scan
=
new
Scanner
(
System
.
in
);
Scanner
scan
=
new
Scanner
(
System
.
in
);
menuSelect
=
scan
.
nextInt
();
menuSelect
=
scan
.
nextInt
();
scan
.
close
();
HashMap
<
Character
,
String
>
codes
=
new
HashMap
<
Character
,
String
>();
HashMap
<
Character
,
String
>
map
=
new
HashMap
<
Character
,
String
>();
map
=
Morse
.
initialise
(
map
);
switch
(
menuSelect
)
{
switch
(
menuSelect
)
{
case
1
:
case
1
:
//
C
onvert from English to morse
//
Get user input and then c
onvert from English to morse
break
;
break
;
case
2
:
case
2
:
//
C
onvert morse to English.
//
Get user input and then c
onvert morse to English.
break
;
break
;
case
3
:
// Print the contents of the map
Morse
.
printMap
(
map
);
}
}
}
}
...
...
src/MorseConverter/Morse.java
View file @
57fce6ea
...
@@ -4,12 +4,64 @@ import java.util.HashMap;
...
@@ -4,12 +4,64 @@ import java.util.HashMap;
public
class
Morse
{
public
class
Morse
{
// Set up a map with all of the morse code values mapped.
public
static
HashMap
<
Character
,
String
>
initialise
(
HashMap
<
Character
,
String
>
map
)
{
map
.
put
(
'a'
,
"101110"
);
map
.
put
(
'b'
,
"1110101010"
);
map
.
put
(
'c'
,
"111010111010"
);
map
.
put
(
'd'
,
"11101010"
);
map
.
put
(
'e'
,
"10"
);
map
.
put
(
'f'
,
"1010111010"
);
map
.
put
(
'g'
,
"1110111010"
);
map
.
put
(
'h'
,
"10101010"
);
map
.
put
(
'i'
,
"1010"
);
map
.
put
(
'j'
,
"10111011101110"
);
map
.
put
(
'k'
,
"1110101110"
);
map
.
put
(
'l'
,
"1011101010"
);
map
.
put
(
'm'
,
"11101110"
);
map
.
put
(
'n'
,
"111010"
);
map
.
put
(
'o'
,
"111011101110"
);
map
.
put
(
'p'
,
"101110111010"
);
map
.
put
(
'q'
,
"11101110101110"
);
map
.
put
(
'r'
,
"10111010"
);
map
.
put
(
's'
,
"101010"
);
map
.
put
(
't'
,
"1110"
);
map
.
put
(
'u'
,
"10101110"
);
map
.
put
(
'v'
,
"1010101110"
);
map
.
put
(
'w'
,
"1011101110"
);
map
.
put
(
'x'
,
"111010101110"
);
map
.
put
(
'y'
,
"11101011101110"
);
map
.
put
(
'z'
,
"111011101010"
);
map
.
put
(
'0'
,
"11101110111011101110"
);
map
.
put
(
'1'
,
"101110111011101110"
);
map
.
put
(
'2'
,
"1010111011101110"
);
map
.
put
(
'3'
,
"10101011101110"
);
map
.
put
(
'4'
,
"101010101110"
);
map
.
put
(
'5'
,
"1010101010"
);
map
.
put
(
'6'
,
"111010101010"
);
map
.
put
(
'7'
,
"11101110101010"
);
map
.
put
(
'8'
,
"1110111011101010"
);
map
.
put
(
'9'
,
"111011101110111010"
);
return
map
;
}
public
static
HashMap
<
Character
,
String
>
initialise
(
HashMap
<
Character
,
String
>
map
)
{
// Turn a string of morse code characters into a sentence
public
static
String
morseToEng
(
String
sentance
,
HashMap
<
Character
,
String
>
map
)
{
return
;
}
map
.
put
(
'a'
,
"10111"
);
return
map
;
// Turn a string of English into morse code
public
static
String
engToMorse
(
String
sentance
,
HashMap
<
Character
,
String
>
map
)
{
return
;
}
// Loop through the map and print it
public
static
void
printMap
(
HashMap
<
Character
,
String
>
map
)
{
// Loop through the map
for
(
Character
letter
:
map
.
keySet
())
{
System
.
out
.
println
(
"Letter: "
+
letter
+
" Value: "
+
map
.
get
(
letter
));
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment