Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
assassment 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
suleman.hussain
assassment 1
Commits
ea6107b0
Commit
ea6107b0
authored
Apr 20, 2022
by
Suleman Hussain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finished
parent
53835ebe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
4 deletions
+22
-4
Complex.class
bin/Complex.class
+0
-0
Complex.java
src/Complex.java
+22
-4
No files found.
bin/Complex.class
View file @
ea6107b0
No preview for this file type
src/Complex.java
View file @
ea6107b0
...
...
@@ -29,23 +29,41 @@ public class Complex {
public
double
magnitude
()
{
return
1.0
;
return
Math
.
sqrt
(
Math
.
pow
(
real
,
2
)+(
Math
.
pow
(
imag
,
2
)))
;
}
public
double
argument
()
{
return
1.0
;
return
Math
.
atan
(
imag
/
real
)
;
}
public
String
toString
()
{
return
""
;
String
imag_string
=
Double
.
toString
(
imag
);
String
real_string
=
Double
.
toString
(
real
);
if
(
real
!=
0
)
{
if
(
imag
!=
0
)
{
if
(
imag
<
0
)
{
String
imag_string_
=
imag_string
.
replace
(
"-"
,
""
);
return
real_string
+
" - "
+
"j"
+
imag_string_
;
}
return
real_string
+
" + "
+
"j"
+
imag_string
;
}
else
{
return
real_string
;
}
}
else
{
return
"j"
+
imag_string
;
}
}
public
Complex
add
(
Complex
complexNum
)
{
Complex
answer
=
new
Complex
(
0.0
,
0.0
);
answer
.
real
=
complexNum
.
real
+
real
;
answer
.
imag
=
complexNum
.
imag
+
imag
;
return
answer
;
}
...
...
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