Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Assignment 04-18
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
emmanuel.gutzmore
Assignment 04-18
Commits
d6ee1508
Commit
d6ee1508
authored
Jan 07, 2019
by
Emman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
c899adb3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
15 deletions
+96
-15
AssessmentPartFour.java
src/AssessmentPartFour.java
+96
-15
No files found.
src/AssessmentPartFour.java
View file @
d6ee1508
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Scanner
;
public
class
AssessmentPartFour
{
List
<
String
>
morseCode
=
new
ArrayList
<
String
>();
public
int
loadMorseFromFile
(
String
filename
)
{
return
0
;
private
char
morseCode
(
String
str
)
{
switch
(
str
)
{
case
".-"
:
return
'a'
;
case
"-..."
:
return
'b'
;
case
"-.-."
:
return
'c'
;
case
"-.."
:
return
'd'
;
case
"."
:
return
'e'
;
case
"..-."
:
return
'f'
;
case
"--."
:
return
'g'
;
case
"...."
:
return
'h'
;
case
".."
:
return
'i'
;
case
".---"
:
return
'j'
;
case
"-.-"
:
return
'k'
;
case
".-.."
:
return
'l'
;
case
"--"
:
return
'm'
;
case
"-."
:
return
'n'
;
case
"---"
:
return
'o'
;
case
".--."
:
return
'p'
;
case
"--.-"
:
return
'q'
;
case
".-."
:
return
'r'
;
case
"..."
:
return
's'
;
case
"-"
:
return
't'
;
case
"..-"
:
return
'u'
;
case
"...-"
:
return
'v'
;
case
".--"
:
return
'w'
;
case
"-..-"
:
return
'x'
;
case
"-.--"
:
return
'y'
;
// for space
case
"--.."
:
return
'z'
;
}
return
'\0'
;
}
public
int
loadMorseFromFile
(
String
filename
)
{
morseCode
.
clear
();
Scanner
sc
;
int
count
=
0
;
String
s
=
""
;
try
{
sc
=
new
Scanner
(
new
File
(
filename
));
while
(
sc
.
hasNext
())
{
String
str
=
sc
.
next
();
if
(!
"/"
.
equals
(
str
))
{
char
ch
=
morseCode
(
str
);
if
(
'\0'
!=
ch
)
{
s
+=
morseCode
(
str
);
count
++;
}
}
else
{
count
++;
s
+=
" "
;
}
}
}
catch
(
FileNotFoundException
e
)
{
}
if
(!
s
.
trim
().
isEmpty
())
{
morseCode
.
add
(
s
);
}
return
count
;
}
public
String
translateMorse
()
{
return
""
;
public
String
translateMorse
()
{
return
morseCode
.
get
(
0
);
}
}
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