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
0753d1a6
Commit
0753d1a6
authored
Nov 22, 2020
by
ABDELMOUDJIB Mohammed el amine
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
e4555d45
No related branches found
No related tags found
No related merge requests found
Pipeline
#419
failed
Nov 22, 2020
Stage: build
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tp6/Turtle.java
+65
-0
65 additions, 0 deletions
tp6/Turtle.java
with
65 additions
and
0 deletions
tp6/Turtle.java
0 → 100644
+
65
−
0
View file @
0753d1a6
import
javax.swing.*
;
import
java.awt.*
;
import
java.security.PublicKey
;
public
class
Turtle
{
public
Color
penColor
;
public
double
angleDirection
;
public
Point
position
;
public
boolean
penDown
;
public
Painter
painter
;
public
Turtle
(
int
width
,
int
height
){
penColor
=
null
;
angleDirection
=
90
;
painter
=
new
Painter
()
{
@Override
public
void
paint
(
Graphics2D
g
,
Object
object
,
int
width
,
int
height
)
{
}
};
penDown
=
false
;
this
.
position
=
new
Point
(
width
/
2
,
height
/
2
);
}
public
void
moveForward
(
double
distance
){
Point
p
=
position
;
Point
position2
=
position
.
translate
(
distance
*
Math
.
cos
(
angleDirection
),
distance
*
Math
.
sin
(
angleDirection
));
if
(
penDown
=
false
){
p
.
drawLine
(
position2
,
painter
,
penColor
);
}
position
=
position2
;
}
public
void
setColor
(
Color
color
){
this
.
penColor
=
color
;
}
public
void
turnLeft
(
double
angle
){
this
.
angleDirection
=
angleDirection
+
angle
;
}
public
void
turnRight
(
double
angle
){
this
.
angleDirection
=
angleDirection
+
angle
;
}
public
void
setPenDown
(){
this
.
penDown
=
true
;
}
public
void
setPenUp
(){
this
.
penDown
=
false
;
}
void
drawString
(
String
sequence
,
double
length
,
double
angle
){
if
(
sequence
==
"A"
){
moveForward
(
length
);
}
if
(
sequence
==
"+"
){
turnRight
(
angle
);
}
if
(
sequence
==
"-"
){
turnLeft
(
angle
);
}
}
}
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