Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
Formative Assessment Complex
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
rhys.may
Formative Assessment Complex
Commits
3b928e73
Commit
3b928e73
authored
Mar 06, 2020
by
rhys.may
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
f23e1349
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
0 deletions
+89
-0
Complex.java
src/Complex.java
+89
-0
No files found.
src/Complex.java
0 → 100644
View file @
3b928e73
public
class
Complex
{
double
realno
,
imagno
;
public
Complex
(
double
d
,
double
e
)
{
// TODO Auto-generated constructor stub
realno
=
d
;
imagno
=
e
;
}
public
Complex
()
{
// TODO Auto-generated constructor stub
realno
=
0
;
imagno
=
0
;
}
public
void
setReal
(
double
q
)
{
realno
=
q
;
}
public
void
setImag
(
double
q
)
{
imagno
=
q
;
}
public
double
real
()
{
// TODO Auto-generated method stub
return
realno
;
}
public
double
imag
()
{
// TODO Auto-generated method stub
return
imagno
;
}
public
double
magnitude
()
{
// TODO Auto-generated method stub
return
Math
.
sqrt
((
Math
.
pow
(
realno
,
2
)
+
Math
.
pow
(
imagno
,
2
)));
}
public
Object
argument
()
{
return
Math
.
atan2
(
realno
,
imagno
);
}
public
Complex
add
(
Complex
b
)
{
// TODO Auto-generated method stub
this
.
realno
=
this
.
realno
+
b
.
realno
;
this
.
imagno
=
this
.
imagno
+
b
.
imagno
;
return
this
;
}
public
String
toString
()
{
String
realno
=
""
;
String
imagno
=
""
;
String
Sign
=
""
;
if
(
this
.
realno
==
0
)
{
realno
=
""
;
}
else
if
(
this
.
realno
>
0
)
{
realno
=
""
+
this
.
realno
;
}
else
if
(
this
.
realno
>
0
)
{
realno
=
""
+
(
Math
.
sqrt
(
Math
.
pow
(
this
.
realno
,
2
)));
}
if
(
this
.
imagno
<
0
)
{
Sign
=
" - "
;
}
else
if
(
this
.
imagno
>
0
)
{
Sign
=
" + "
;
}
else
{
Sign
=
""
;
}
if
(
this
.
realno
==
0
)
{
Sign
=
""
;
}
if
(
this
.
imagno
==
0
)
{
imagno
=
""
;
}
else
if
(
this
.
imagno
!=
0
)
{
double
l
=
Math
.
sqrt
(
Math
.
pow
(
this
.
imagno
,
2
));
imagno
=
"j"
+
l
;
}
return
(
realno
+
Sign
+
imagno
);
}
}
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