Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dia004
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Joel Florentin
dia004
Commits
1f00e1ef
Commit
1f00e1ef
authored
Oct 20, 2021
by
Joel Florentin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial
parents
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
148 additions
and
0 deletions
+148
-0
EjemploInterface.java
+148
-0
No files found.
EjemploInterface.java
0 → 100644
View file @
1f00e1ef
public
class
EjemploInterface
{
public
static
void
main
(
String
[]
args
)
{
Forma
cir
=
new
Circulo
(
"Rojo"
,
5
.
f
);
Forma
cuad
=
new
Rectangulo
(
"Amarillo"
,
5
.
f
,
3
.
f
);
Cartel
cartel1
=
new
Cartel
(
cir
,
"Peligro"
);
Cartel
cartel2
=
new
Cartel
(
cuad
,
"Atencion"
);
System
.
out
.
println
(
cartel1
.
cuadraTexto
());
System
.
out
.
println
(
cartel2
.
cuadraTexto
());
}
}
interface
Forma
{
public
String
getColor
();
public
void
setColor
(
String
color
);
public
float
getPerimetro
();
public
float
getArea
();
public
float
getLongitud
();
}
class
Cartel
{
private
Forma
forma
;
private
String
texto
;
public
Cartel
(
Forma
forma
,
String
texto
)
{
this
.
forma
=
forma
;
this
.
texto
=
texto
;
}
public
Forma
getForma
(){
return
this
.
forma
;
}
public
void
setForma
(
Forma
forma
){
this
.
forma
=
forma
;
}
public
String
getTexto
(){
return
this
.
texto
;
}
public
void
setTexto
(
String
texto
){
this
.
texto
=
texto
;
}
public
boolean
cuadraTexto
(){
return
this
.
texto
.
length
()
<
this
.
forma
.
getLongitud
();
}
}
class
Circulo
implements
Forma
{
private
String
color
;
private
float
radio
;
public
Circulo
(
String
color
,
float
radio
)
{
this
.
color
=
color
;
this
.
radio
=
radio
;
}
@Override
public
String
getColor
()
{
return
color
;
}
@Override
public
void
setColor
(
String
color
)
{
this
.
color
=
color
;
}
@Override
public
float
getPerimetro
()
{
return
(
float
)
Math
.
PI
*
2
*
radio
;
}
@Override
public
float
getArea
()
{
return
(
float
)
Math
.
PI
*
radio
*
radio
;
}
@Override
public
float
getLongitud
()
{
// TODO Auto-generated method stub
return
2
*
radio
;
}
}
class
Rectangulo
implements
Forma
{
private
String
color
;
private
float
largo
;
private
float
ancho
;
public
Rectangulo
(
String
color
,
float
largo
,
float
ancho
)
{
this
.
color
=
color
;
this
.
largo
=
largo
;
this
.
ancho
=
ancho
;
}
@Override
public
String
getColor
()
{
return
color
;
}
@Override
public
void
setColor
(
String
color
)
{
this
.
color
=
color
;
}
@Override
public
float
getPerimetro
()
{
return
2
*(
largo
+
ancho
);
}
@Override
public
float
getArea
()
{
return
largo
*
ancho
;
}
public
float
getAncho
()
{
return
ancho
;
}
public
float
getLongitud
()
{
return
largo
;
}
public
void
setAncho
(
float
ancho
)
{
this
.
ancho
=
ancho
;
}
public
void
setLongitud
(
float
largo
)
{
this
.
largo
=
largo
;
}
}
\ No newline at end of file
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