Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Assessment 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
jose.alencastro
Assessment 1
Commits
fd790f99
Commit
fd790f99
authored
May 16, 2022
by
jose.alencastro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ok
parent
c094b452
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
17 deletions
+36
-17
Complex.class
Complex.class
+0
-0
Complex.java
Complex.java
+36
-17
No files found.
Complex.class
View file @
fd790f99
No preview for this file type
Complex.java
View file @
fd790f99
...
@@ -30,25 +30,44 @@ public class Complex
...
@@ -30,25 +30,44 @@ public class Complex
public
double
magnitude
()
public
double
magnitude
()
{
{
return
1.0
;
double
magnitude
=
Math
.
sqrt
(
Math
.
pow
(
this
.
real
,
2
)
+
Math
.
pow
(
this
.
imag
,
2
));
return
magnitude
;
}
}
public
double
argument
()
public
double
argument
()
{
{
return
1.0
;
return
Math
.
atan2
(
imag
,
real
)
;
}
}
public
String
toString
()
public
String
toString
()
{
{
return
""
;
String
imagString
=
Double
.
toString
(
imag
);
String
realString
=
Double
.
toString
(
real
);
if
(
real
!=
0
)
{
if
(
imag
!=
0
)
{
if
(
imag
<
0
)
{
String
imagString2
=
imagString
.
replace
(
"-"
,
""
);
return
realString
+
" - "
+
"j"
+
imagString2
;
}
return
realString
+
" + "
+
"j"
+
imagString
;
}
else
{
return
realString
;
}
}
return
realString
;
}
}
public
Complex
add
(
Complex
complexNum
)
public
Complex
add
(
Complex
complexNum
)
{
{
Complex
answer
=
new
Complex
(
0.0
,
0.0
);
Complex
answer
=
new
Complex
(
0.0
,
0.0
);
answer
.
real
=
complexNum
.
real
+
real
;
answer
.
imag
=
complexNum
.
imag
+
imag
;
return
answer
;
return
answer
;
}
}
}
}
\ No newline at end of file
\ No newline at end of file
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