Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
assessmentExercises
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
cosmina.dunca
assessmentExercises
Commits
ee33845b
Commit
ee33845b
authored
Mar 16, 2022
by
cosmina.dunca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finished
parent
f2a76a88
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
3 deletions
+35
-3
App.class
bin/App.class
+0
-0
Complex.class
bin/Complex.class
+0
-0
App.class
src/App.class
+0
-0
App.java
src/App.java
+32
-1
Complex.class
src/Complex.class
+0
-0
Complex.java
src/Complex.java
+3
-2
No files found.
bin/App.class
View file @
ee33845b
No preview for this file type
bin/Complex.class
View file @
ee33845b
No preview for this file type
src/App.class
View file @
ee33845b
No preview for this file type
src/App.java
View file @
ee33845b
public
class
App
{
public
class
App
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Complex
a
=
new
Complex
(
4.2
,
5.7
);
// First test
/* Complex a = new Complex(4.2, 5.7);
a.imag();
a.imag();
a.real();
a.real();
System.out.println(a.imag);
System.out.println(a.real);
System.out.println(a.real());
System.out.println(a.imag()); -> correct */
// Second test
/* Complex a = new Complex(9.6, 11.5);
System.out.println(a.magnitude()); -> correct */
// Third test
/* Complex a = new Complex(9.6, 11.5);
System.out.println(a.argument()); -> correct */
// Fourth test
/* Complex a = new Complex(1.2, 3.4);
System.out.println(a.toString());
Complex b = new Complex(1.2, 0.0);
System.out.println(b.toString());
Complex c = new Complex(0.0, 9.3);
System.out.println(c.toString());
Complex d = new Complex(1.2, -3.4);
System.out.println(d.toString()); -> correct */
// Fifth test
Complex
a
=
new
Complex
(
6.6
,
12.9
);
Complex
b
=
new
Complex
(
13.1
,
13.5
);
Complex
c
=
a
.
add
(
b
);
System
.
out
.
println
(
c
.
real
());
System
.
out
.
println
(
c
.
imag
());
}
}
}
}
src/Complex.class
View file @
ee33845b
No preview for this file type
src/Complex.java
View file @
ee33845b
...
@@ -2,6 +2,7 @@ public class Complex {
...
@@ -2,6 +2,7 @@ public class Complex {
public
double
real
;
public
double
real
;
public
double
imag
;
public
double
imag
;
public
double
d
;
public
Complex
()
public
Complex
()
{
{
...
@@ -13,7 +14,7 @@ public class Complex {
...
@@ -13,7 +14,7 @@ public class Complex {
{
{
this
.
real
=
r
;
this
.
real
=
r
;
this
.
imag
=
i
;
this
.
imag
=
i
;
//double
d = Math.atan2(i,r);
this
.
d
=
Math
.
atan2
(
i
,
r
);
}
}
public
double
imag
()
public
double
imag
()
...
@@ -33,7 +34,7 @@ public class Complex {
...
@@ -33,7 +34,7 @@ public class Complex {
public
double
argument
()
public
double
argument
()
{
{
return
Math
.
atan2
(
this
.
imag
,
this
.
real
)
;
return
d
;
}
}
public
String
toString
()
public
String
toString
()
...
...
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