Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Georgii Aksenov
2021-pb162-seminar-project
Commits
f6a20774
Commit
f6a20774
authored
Mar 03, 2021
by
Georgii Aksenov
Browse files
iteration 01 done
parent
4630422c
Pipeline
#67628
failed with stage
in 8 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
src/main/java/cz/muni/fi/pb162/project/Demo.java
View file @
f6a20774
package
cz.muni.fi.pb162.project
;
package
cz.muni.fi.pb162.project
;
import
cz.muni.fi.pb162.project.geometry.Vertex2D
;
/**
/**
* Class for running main method.
* Class for running main method.
*
*
* @author
TODO: put your name here
* @author
Georgii Aksenov <xaksenov@fi.muni.cz>
*/
*/
public
class
Demo
{
public
class
Demo
{
/**
/**
*
Runs the code
.
*
prints info for two vertices of fixed coordinates
.
*
*
* @param args command line arguments, will be ignored
* @param args command line arguments, will be ignored
*/
*/
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
Vertex2D
v1
=
newVertex
(
2
,
3
);
Vertex2D
v2
=
newVertex
(
1
,
1
);
v1
.
move
(
v2
);
System
.
out
.
println
(
"Hello world!"
);
System
.
out
.
println
(
v1
.
getInfo
());
System
.
out
.
println
(
v2
.
getInfo
());
}
/**
* Creates new instance of Vertex2D.
*
* @param x coordinate for new vector
* @param y coordinate for new vector
* @return new Vertex2D.
*/
private
static
Vertex2D
newVertex
(
double
x
,
double
y
)
{
Vertex2D
vertex
=
new
Vertex2D
();
vertex
.
setX
(
x
);
vertex
.
setY
(
y
);
return
vertex
;
}
}
}
}
src/main/java/cz/muni/fi/pb162/project/geometry/Vertex2D.java
0 → 100644
View file @
f6a20774
package
cz.muni.fi.pb162.project.geometry
;
/**
* @author Georgii Aksenov <xaksenov@fi.muni.cz>
*/
public
class
Vertex2D
{
private
double
X
=
0
;
private
double
Y
=
0
;
public
double
getX
()
{
return
X
;
}
public
void
setX
(
double
x
)
{
X
=
x
;
}
public
double
getY
()
{
return
Y
;
}
public
void
setY
(
double
y
)
{
Y
=
y
;
}
/**
* To get string representation.
*
* @return string representation.
*/
public
String
getInfo
()
{
return
String
.
format
(
"[%.1f, %.1f]"
,
X
,
Y
);
}
/**
* To get sum of coordinates.
*
* @return sum of coordinates.
*/
public
double
sumCoordinates
()
{
return
X
+
Y
;
}
/**
* Moves the vertex.
*
* @param vertex is added to this vertex.
*/
public
void
move
(
Vertex2D
vertex
)
{
X
+=
vertex
.
X
;
Y
+=
vertex
.
Y
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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