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
8c436870
Commit
8c436870
authored
Jun 03, 2022
by
sam.pople
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial commit
parent
f8ea15b0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
11 deletions
+28
-11
Complex.class
bin/Complex.class
+0
-0
App.class
src/App.class
+0
-0
Complex.java
src/Complex.java
+28
-11
No files found.
bin/Complex.class
View file @
8c436870
No preview for this file type
src/App.class
0 → 100644
View file @
8c436870
File added
src/Complex.java
View file @
8c436870
public
class
Complex
{
public
class
Complex
{
public
double
real
;
public
double
real
;
public
double
imag
;
public
double
imag
e
;
public
Complex
()
public
Complex
()
{
{
real
=
0
;
real
=
0
;
imag
=
0
;
imag
e
=
0
;
}
}
public
Complex
(
double
r
,
double
i
)
public
Complex
(
double
r
,
double
i
)
{
{
real
=
r
;
real
=
r
;
imag
=
i
;
image
=
i
;
double
d
=
Math
.
atan2
(
i
,
r
);
}
}
public
double
imag
()
public
double
imag
()
{
{
return
imag
;
return
imag
e
;
}
}
public
double
real
()
public
double
real
()
...
@@ -29,24 +28,42 @@ public class Complex {
...
@@ -29,24 +28,42 @@ public class Complex {
public
double
magnitude
()
public
double
magnitude
()
{
{
return
1.0
;
return
Math
.
sqrt
(
this
.
real
()
*
this
.
real
()
+
this
.
imag
()
*
this
.
imag
())
;
}
}
public
double
argument
()
public
double
argument
()
{
{
return
1.0
;
return
Math
.
atan2
(
this
.
imag
(),
this
.
real
())
;
}
}
public
String
toString
()
public
String
toString
()
{
{
return
""
;
String
str
=
""
;
if
(
this
.
real
()
!=
0
)
{
str
=
str
+
this
.
real
();
if
(
this
.
image
>
0
)
{
str
=
str
+
" + "
;
}
if
(
this
.
image
<
0
)
{
str
=
str
+
" - "
;
}
}
if
(
this
.
image
!=
0
)
{
str
=
str
+
"j"
+
Math
.
abs
(
this
.
imag
());
}
return
str
;
}
}
public
Complex
add
(
Complex
complex
Num
)
public
Complex
add
(
Complex
complex
)
{
{
Complex
answer
=
new
Complex
(
0.0
,
0.0
);
Complex
answer
value
=
new
Complex
(
this
.
real
()
+
complex
.
real
(),
this
.
imag
()
+
complex
.
imag
()
);
return
answer
;
return
answer
value
;
}
}
...
...
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