Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Part04
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
Assessment
Part04
Commits
1cbc0815
Commit
1cbc0815
authored
Dec 18, 2018
by
neil.whitehead
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
12:03 18/12/18
parent
bdbea1a8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
9 deletions
+38
-9
AssessmentPartFour.java
src/AssessmentPartFour.java
+38
-9
No files found.
src/AssessmentPartFour.java
View file @
1cbc0815
...
@@ -38,8 +38,6 @@ public class AssessmentPartFour
...
@@ -38,8 +38,6 @@ public class AssessmentPartFour
{
{
System
.
out
.
println
(
"error"
);
System
.
out
.
println
(
"error"
);
}
}
System
.
out
.
println
(
filename
+
" "
+
morseCode
.
size
());
return
morseCode
.
size
();
return
morseCode
.
size
();
}
}
...
@@ -49,18 +47,49 @@ public class AssessmentPartFour
...
@@ -49,18 +47,49 @@ public class AssessmentPartFour
public
String
translateMorse
()
public
String
translateMorse
()
{
{
System
.
out
.
println
(
"translate"
);
System
.
out
.
println
(
morseCode
.
size
());
System
.
out
.
println
(
morseCode
.
get
(
0
));
for
(
int
i
=
0
;
i
<
morseCode
.
size
();
i
++)
for
(
int
i
=
0
;
i
<
morseCode
.
size
();
i
++)
{
{
System
.
out
.
println
(
morseCode
.
get
(
i
));
System
.
out
.
println
(
morseCode
.
get
(
i
)
+
" "
+
(
morseCode
.
get
(
i
)).
length
()
);
}
}
String
strTranslated
=
"strTranslated "
;
String
[][]
strMorseArray
=
{{
" "
,
"E"
,
"T"
},
// have 1 char
{
"/"
,
"."
,
"-"
},
{
"A"
,
"I"
,
"N"
,
"M"
},
// have 2 char
{
".-"
,
".."
,
"-."
,
"--"
},
{
"D"
,
"G"
,
"K"
,
"O"
,
"R"
,
"S"
,
"U"
,
"W"
},
// have 3 char
{
"-.."
,
"--."
,
"-.-"
,
"---"
,
".-."
,
"..."
,
"..-"
,
".--"
},
{
"B"
,
"C"
,
"F"
,
"H"
,
"J"
,
"L"
,
"P"
,
"Q"
,
"V"
,
"X"
,
"Y"
,
"Z"
},
// have 4 char
{
"-..."
,
"-.-."
,
"..-."
,
"...."
,
".---"
,
".-.."
,
".--."
,
"--.-"
,
"..._"
,
"-..-"
,
"-.--"
,
"--.."
},
{
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
,
"7"
,
"8"
,
"9"
,
"0"
},
// have 5 char
{
".----"
,
"..---"
,
"...--"
,
"....-"
,
"....."
,
"-...."
,
"--..."
,
"---.."
,
"----."
,
"-----"
}};
for
(
int
i
=
0
;
i
<
morseCode
.
size
();
i
++)
{
int
x
=
(((
morseCode
.
get
(
i
)).
length
())
*
2
)
-
1
;
for
(
int
y
=
0
;
y
<
strMorseArray
[
x
].
length
;
y
++)
{
System
.
out
.
println
(
"something"
);
System
.
out
.
println
(
strMorseArray
[
x
-
1
][
y
]);
if
(
strMorseArray
[
x
][
y
].
contains
(
morseCode
.
get
(
i
)))
{
strTranslated
.
concat
(
strMorseArray
[
x
-
1
][
y
]);
strMorseArray
[
x
-
1
][
y
].
concat
(
strTranslated
);
break
;
}
}
}
//NEED TO SORT OUT LOOPS. WHY HAVE I DIVIDED THE MORSE ARRAY LIKE THIS AGAIN? WHY AREN'T MY STRINGS CONCATNATING?
System
.
out
.
println
(
strTranslated
);
return
""
;
return
""
;
}
}
...
...
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