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
gabriel.penman
Assessment exercise 1
Commits
3ac451ce
Commit
3ac451ce
authored
Mar 09, 2022
by
Volcanex
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished
parent
bf380f35
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
5 deletions
+27
-5
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
+27
-5
No files found.
bin/App.class
View file @
3ac451ce
No preview for this file type
bin/AppTest.class
View file @
3ac451ce
No preview for this file type
bin/Complex.class
View file @
3ac451ce
No preview for this file type
src/Complex.java
View file @
3ac451ce
public
class
Complex
{
public
double
real
;
...
...
@@ -14,7 +16,7 @@ public class Complex {
{
real
=
r
;
imag
=
i
;
double
d
=
Math
.
atan2
(
i
,
r
);
}
public
double
imag
()
...
...
@@ -29,22 +31,42 @@ public class Complex {
public
double
magnitude
()
{
return
1.0
;
return
Math
.
sqrt
(
this
.
real
()*
this
.
real
()
+
this
.
imag
()*
this
.
imag
())
;
}
public
double
argument
()
{
return
1.0
;
return
Math
.
atan2
(
this
.
imag
(),
this
.
real
())
;
}
public
String
toString
()
{
return
""
;
String
string
=
""
;
if
(
this
.
real
()
!=
0
){
string
=
string
+
this
.
real
();
if
(
this
.
imag
>
0
)
{
string
=
string
+
" + "
;
}
if
(
this
.
imag
<
0
)
{
string
=
string
+
" - "
;
}
}
if
(
this
.
imag
!=
0
)
{
string
=
string
+
"j"
+
Math
.
abs
(
this
.
imag
());
}
return
string
;
}
public
Complex
add
(
Complex
complexNum
)
{
Complex
answer
=
new
Complex
(
0.0
,
0.0
);
Complex
answer
=
new
Complex
(
this
.
real
()+
complexNum
.
real
(),
this
.
imag
()+
complexNum
.
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