Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Assessment Exercise 1
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
sam.pople
Assessment Exercise 1
Commits
83b250af
Commit
83b250af
authored
Jun 05, 2022
by
sam.pople
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Final finish
parent
d0b44f50
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
16 deletions
+8
-16
Complex.java
src/Complex.java
+8
-16
No files found.
src/Complex.java
View file @
83b250af
...
...
@@ -8,57 +8,49 @@ public class Complex {
real
=
0
;
imag
=
0
;
}
public
Complex
(
double
r
,
double
i
)
{
real
=
r
;
imag
=
i
;
}
public
double
imag
()
{
return
imag
;
}
public
double
real
()
{
return
real
;
}
public
double
magnitude
()
{
return
Math
.
sqrt
(
this
.
real
()
*
this
.
real
()
+
this
.
imag
()
*
this
.
imag
(
));
return
Math
.
sqrt
(
Math
.
pow
(
real
,
2
)
+
Math
.
pow
(
imag
,
2
));
}
public
double
argument
()
{
return
Math
.
atan2
(
this
.
imag
(),
this
.
real
()
);
return
Math
.
atan2
(
imag
,
real
);
}
public
String
toString
()
{
String
str
=
""
;
if
(
this
.
real
()
!=
0
)
{
str
=
str
+
this
.
real
();
if
(
this
.
imag
>
0
)
{
str
=
str
+
" + "
;
}
if
(
this
.
imag
<
0
)
{
str
=
str
+
" - "
;
}
if
(
this
.
imag
>
0
)
{
str
=
str
+
" + "
;
}
}
if
(
this
.
imag
!=
0
)
{
str
=
str
+
"j"
+
Math
.
abs
(
this
.
imag
());
}
return
str
;
}
public
Complex
add
(
Complex
complex
)
public
Complex
add
(
Complex
complex
Num
)
{
Complex
answervalue
=
new
Complex
(
this
.
real
()
+
complex
.
real
(),
this
.
imag
()
+
complex
.
imag
());
return
answer
value
;
Complex
value
=
new
Complex
(
this
.
real
()
+
complexNum
.
real
(),
this
.
imag
()
+
complexNum
.
imag
());
return
value
;
}
...
...
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