pastebin
| #1 paste tool since 2002
create new paste
tools
api
archive
real-time
faq
pastebin
Follow @pastebin
create new paste
trending pastes
sign up
login
my settings
my profile
My Pastes
Public Pastes
Untitled
8 sec ago
Check it Jens
10 sec ago
Untitled
7 sec ago
Untitled
8 sec ago
Watch Wake Forest vs Cl...
34 sec ago
Untitled
12 sec ago
Untitled
14 sec ago
Ravenskye City Ultimate...
27 sec ago
Layout Width
Share Pastebin
Aldian
By: a guest | Jul 5th, 2009 | Syntax:
Java
| Size: 1.06 KB | Hits: 191 | Expires: Never
Download
|
Raw
|
Embed
|
Report abuse
public
class
VaisseauSpatial
{
String
nom
=
null
;
String
couleur
=
"bleu"
;
int
nombre_de_canons
=
3
;
int
vitesse
=
0
;
static
int
nombre_vaisseaux
=
0
;
VaisseauSpatial
(
String
nom
)
{
nombre_vaisseaux
++;
this
.
nom
=
nom
;
}
VaisseauSpatial
(
String
nom,
String
couleur,
int
nombre_de_canons
)
{
this
(
nom
)
;
this
.
couleur
=
couleur
;
this
.
nombre_de_canons
=
nombre_de_canons
;
}
void
accelerer
(
)
{
vitesse
++
;
System
.
out
.
println
(
"le vaisseau "
+
nom
+
" accélère et sa vitesse passe à: "
+
vitesse
)
;
}
void
ralentir
(
)
{
vitesse
--
;
if
(
vitesse
<
0
)
vitesse
=
0
;
System
.
out
.
println
(
"le vaisseau "
+
nom
+
" déccélère et sa vitesse passe à: "
+
vitesse
)
;
}
public
static
void
main
(
String
[
]
args
)
{
VaisseauSpatial vaisseau1
=
new
VaisseauSpatial
(
"Liberty"
)
;
VaisseauSpatial vaisseau2
=
new
VaisseauSpatial
(
"Emeraude"
,
"rouge"
,8
)
;
vaisseau1.
accelerer
(
)
;
vaisseau2.
accelerer
(
)
;
vaisseau1.
ralentir
(
)
;
System
.
out
.
println
(
"Il y a actuellement "
+
nombre_vaisseaux
+
" vaisseaux dans l'espace"
)
;
}
}
create new paste
|
create new version of this paste
RAW Paste Data