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
31daeb36
Commit
31daeb36
authored
Jun 05, 2022
by
sam.pople
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
worked again
parent
22a525a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
12 deletions
+8
-12
Complex.java
src/Complex.java
+8
-12
No files found.
src/Complex.java
View file @
31daeb36
public
class
Complex
{
public
double
real
;
public
double
imag
e
;
public
double
imag
;
public
Complex
()
{
real
=
0
;
imag
e
=
0
;
imag
=
0
;
}
public
Complex
(
double
r
,
double
i
)
{
real
=
r
;
image
=
i
;
imag
=
i
;
}
public
double
imag
()
{
return
imag
e
;
return
imag
;
}
public
double
real
()
...
...
@@ -35,30 +36,25 @@ public class Complex {
{
return
Math
.
atan2
(
this
.
imag
(),
this
.
real
());
}
public
String
toString
()
{
String
str
=
""
;
if
(
this
.
real
()
!=
0
)
{
str
=
str
+
this
.
real
();
if
(
this
.
imag
e
>
0
)
{
if
(
this
.
imag
>
0
)
{
str
=
str
+
" + "
;
}
if
(
this
.
imag
e
<
0
)
{
if
(
this
.
imag
<
0
)
{
str
=
str
+
" - "
;
}
}
if
(
this
.
image
!=
0
)
{
if
(
this
.
imag
!=
0
)
{
str
=
str
+
"j"
+
Math
.
abs
(
this
.
imag
());
}
return
str
;
}
public
Complex
add
(
Complex
complex
)
{
Complex
answervalue
=
new
Complex
(
this
.
real
()
+
complex
.
real
(),
this
.
imag
()
+
complex
.
imag
());
...
...
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