Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
Java Assignment 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
thomas.fuller
Java Assignment Exercise 1
Commits
0c3f9b1b
Commit
0c3f9b1b
authored
May 22, 2022
by
thomas.fuller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finished
parent
de95c2bd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
7 deletions
+18
-7
App.class
src/App.class
+0
-0
App.java
src/App.java
+7
-1
Complex.class
src/Complex.class
+0
-0
Complex.java
src/Complex.java
+11
-6
No files found.
src/App.class
0 → 100644
View file @
0c3f9b1b
File added
src/App.java
View file @
0c3f9b1b
public
class
App
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
out
.
println
(
"Hello, World!"
);
Complex
a
=
new
Complex
(
6.6
,
12.9
);
Complex
b
=
new
Complex
(
13.1
,
13.5
);
System
.
out
.
println
(
a
.
magnitude
());
System
.
out
.
println
(
b
.
argument
());
Complex
c
=
a
.
add
(
b
);
System
.
out
.
println
(
c
.
toString
());
}
}
src/Complex.class
0 → 100644
View file @
0c3f9b1b
File added
src/Complex.java
View file @
0c3f9b1b
...
...
@@ -29,23 +29,28 @@ public class Complex {
public
double
magnitude
()
{
return
1.0
;
double
x
=
this
.
real
;
double
y
=
this
.
imag
;
return
Math
.
hypot
(
x
,
y
);
}
public
double
argument
()
{
return
1.0
;
return
Math
.
atan2
(
imag
,
real
)
;
}
public
String
toString
()
{
return
""
;
public
String
toString
()
{
if
(
imag
==
0
)
return
real
+
""
;
if
(
real
==
0
)
return
"j"
+
imag
;
if
(
imag
<
0
)
return
real
+
" - "
+
"j"
+(-
imag
);
return
real
+
" + "
+
"j"
+
imag
;
}
public
Complex
add
(
Complex
complexNum
)
{
Complex
answer
=
new
Complex
(
0.0
,
0.0
);
answer
.
real
=
this
.
real
+
complexNum
.
real
;
answer
.
imag
=
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