Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
G1_Abdelmoudjib_G3_NABI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ABDELMOUDJIB Mohammed el amine
G1_Abdelmoudjib_G3_NABI
Commits
e4555d45
Commit
e4555d45
authored
Nov 22, 2020
by
ABDELMOUDJIB Mohammed el amine
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
27df0c87
No related branches found
No related tags found
No related merge requests found
Pipeline
#418
canceled
Nov 22, 2020
Stage: build
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tp6/Triangle.java
+66
-0
66 additions, 0 deletions
tp6/Triangle.java
with
66 additions
and
0 deletions
tp6/Triangle.java
0 → 100644
+
66
−
0
View file @
e4555d45
import
tp2.lib.Painter
;
import
java.awt.*
;
import
java.util.Random
;
import
static
tp2
.
lib
.
Tools
.
sleep
;
/**
* Created by Arnaud Labourel on 15/10/2018.
*/
public
class
Triangle
implements
Shape
{
private
final
Point
[]
vertices
;
public
Triangle
(
Point
p1
,
Point
p2
,
Point
p3
)
{
vertices
=
new
Point
[]{
p1
,
p2
,
p3
};
}
private
Triangle
(
Point
[]
vertices
){
this
.
vertices
=
vertices
;
}
@Override
public
double
getPerimeter
()
{
Point
p
=
vertices
[
1
];
//double per= p2.getX()-p;
return
0
;
}
@Override
public
void
draw
(
Painter
painter
,
Color
color
)
{
Point
p1
=
vertices
[
1
];
Point
p2
=
vertices
[
2
];
Point
p3
=
vertices
[
3
];
painter
.
addLine
(
p1
.
x
,
p2
.
y
,
p2
.
x
,
p2
.
y
,
color
);
painter
.
addLine
(
p2
.
x
,
p2
.
y
,
p3
.
x
,
p3
.
y
,
color
);
painter
.
addLine
(
p3
.
x
,
p3
.
y
,
p1
.
x
,
p1
.
y
,
color
);
}
@Override
public
Shape
translate
(
int
dx
,
int
dy
)
{
return
new
Triangle
(
vertices
[
1
].
translate
(
dx
,
dy
),
vertices
[
2
].
translate
(
dx
,
dy
),
vertices
[
3
].
translate
(
dx
,
dy
));
}
@Override
public
double
getArea
()
{
return
0
;
}
public
static
void
test_Triangle
(
Painter
painter
){
Point
p1
=
new
Point
(
100
,
100
);
Point
p2
=
new
Point
(
200
,
100
);
Point
p3
=
new
Point
(
100
,
300
);
Random
random
=
new
Random
();
Shape
r
=
new
Triangle
(
p1
,
p2
,
p3
);
r
.
draw
(
painter
,
Color
.
black
);
for
(
int
i
=
30
;
i
<
400
;
i
+=
30
)
{
Shape
t2
=
r
.
translate
(
i
,
i
);
sleep
(
100
);
t2
.
draw
(
painter
,
new
Color
(
random
.
nextFloat
(),
random
.
nextFloat
(),
random
.
nextFloat
()));
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment