Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Assessment1
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.drinkwater
Assessment1
Commits
1e82dadf
Commit
1e82dadf
authored
May 13, 2022
by
sam.drinkwater
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
main
parent
de95c2bd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
7 deletions
+30
-7
App.class
bin/App.class
+0
-0
AppTest.class
bin/AppTest.class
+0
-0
Complex.class
bin/Complex.class
+0
-0
Complex.java
src/Complex.java
+30
-7
No files found.
bin/App.class
View file @
1e82dadf
No preview for this file type
bin/AppTest.class
View file @
1e82dadf
No preview for this file type
bin/Complex.class
View file @
1e82dadf
No preview for this file type
src/Complex.java
View file @
1e82dadf
...
...
@@ -29,25 +29,48 @@ public class Complex {
public
double
magnitude
()
{
return
1.0
;
double
answer
=
Math
.
sqrt
((
real
*
real
)+(
imag
*
imag
));
return
answer
;
}
public
double
argument
()
{
return
1.0
;
double
d
=
Math
.
atan2
(
imag
,
real
);
return
d
;
}
public
String
toString
()
{
if
(
imag
>
0
&&
real
>
0
){
String
positive
=
real
+
" + j"
+
imag
;
return
positive
;
}
else
if
(
imag
==
0.0
){
String
no_imag
=
real
+
""
;
return
no_imag
;
}
else
if
(
imag
>
0
&&
real
==
0.0
){
String
no_real
=
"j"
+
imag
;
return
no_real
;
}
else
if
(
imag
<
0
&&
real
>
0
){
String
str
=
imag
+
""
;
String
strNew
=
str
.
replace
(
"-"
,
""
);
String
negative
=
real
+
" - j"
+
strNew
;
return
negative
;
}
return
""
;
}
public
Complex
add
(
Complex
complexNum
)
{
Complex
answer
=
new
Complex
(
0.0
,
0.0
);
return
answer
;
public
Complex
add
(
Complex
complexNum
){
Complex
res
=
new
Complex
(
0
,
0
);
Complex
a
=
new
Complex
(
real
,
imag
);
res
.
real
=
complexNum
.
real
+
a
.
real
;
res
.
imag
=
complexNum
.
imag
+
a
.
imag
;
return
res
;
}
}
\ 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