generated from Andressep/java-codespace
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Vinceto/developer
M4 Arreglos y Archivos D21 | Desafío - Sistema Automotora (Parte II)
- Loading branch information
Showing
12 changed files
with
650 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package D21; | ||
|
||
public class Bus extends Vehiculos { | ||
public Bus(String color, String patente, int cantidadAsientos, int stock) { | ||
super(color, patente, cantidadAsientos, stock); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return super.toString(); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package D21; | ||
|
||
public class Cliente extends Persona { | ||
public Cliente(String rut, String nombre, int edad, String direccion) { | ||
super(rut, nombre, edad, direccion); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package D21; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
Vendedor vendedor1 = new Vendedor("12345678-9", "Juan Pérez", 40, "Av. Siempre Viva 742"); | ||
Vendedor vendedor2 = new Vendedor("87654321-0", "Ana García", 35, "Calle Verdadera 321"); | ||
List<Vendedor> vendedores = Arrays.asList(vendedor1, vendedor2); | ||
|
||
Cliente cliente = new Cliente("98765432-1", "María López", 30, "Calle Falsa 123"); | ||
|
||
Vehiculos taxi = new Taxi("Rojo", "ABC123", 4, 10, 1500); | ||
Vehiculos bus = new Bus("Azul", "XYZ789", 50, 5); | ||
Vehiculos minibus = new MiniBus("Verde", "DEF456", 20, 3, "Interurbano"); | ||
List<Vehiculos> vehiculos = Arrays.asList(taxi, bus, minibus); | ||
|
||
Tienda tienda = new Tienda("autosLatam", vendedores, vehiculos); | ||
|
||
Venta venta1 = new Venta(cliente, vendedor1, tienda, taxi); | ||
venta1.realizarVenta(); | ||
|
||
Venta venta2 = new Venta(cliente, vendedor2, tienda, taxi); | ||
venta2.realizarVenta(); | ||
|
||
System.out.println("Detalles de la tienda después de las ventas:"); | ||
System.out.println(tienda); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package D21; | ||
|
||
public class MiniBus extends Vehiculos { | ||
private String tipoViaje; | ||
|
||
public MiniBus(String color, String patente, int cantidadAsientos, int stock, String tipoViaje) { | ||
super(color, patente, cantidadAsientos, stock); | ||
this.tipoViaje = tipoViaje; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return super.toString() + ", Tipo de Viaje: " + tipoViaje; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<mxfile host="app.diagrams.net" modified="2024-06-04T00:29:10.378Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36" etag="WEpikfLyy_NOopRz7z56" version="24.4.13" type="github"> | ||
<diagram id="C5RBs43oDa-KdzZeNtuy" name="Page-1"> | ||
<mxGraphModel dx="2261" dy="738" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"> | ||
<root> | ||
<mxCell id="WIyWlLk6GJQsqaUBKTNV-0" /> | ||
<mxCell id="WIyWlLk6GJQsqaUBKTNV-1" parent="WIyWlLk6GJQsqaUBKTNV-0" /> | ||
<mxCell id="zkfFHV4jXpPFQw0GAbJ--0" value="Persona" style="swimlane;fontStyle=2;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeLast=0;collapsible=1;marginBottom=0;rounded=0;shadow=0;strokeWidth=1;" parent="WIyWlLk6GJQsqaUBKTNV-1" vertex="1"> | ||
<mxGeometry x="235" y="60" width="160" height="192" as="geometry"> | ||
<mxRectangle x="230" y="140" width="160" height="26" as="alternateBounds" /> | ||
</mxGeometry> | ||
</mxCell> | ||
<mxCell id="zkfFHV4jXpPFQw0GAbJ--1" value="- nombre" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="zkfFHV4jXpPFQw0GAbJ--0" vertex="1"> | ||
<mxGeometry y="26" width="160" height="26" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="zkfFHV4jXpPFQw0GAbJ--2" value="- rut" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rounded=0;shadow=0;html=0;" parent="zkfFHV4jXpPFQw0GAbJ--0" vertex="1"> | ||
<mxGeometry y="52" width="160" height="28" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="zkfFHV4jXpPFQw0GAbJ--3" value="- altura" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rounded=0;shadow=0;html=0;" parent="zkfFHV4jXpPFQw0GAbJ--0" vertex="1"> | ||
<mxGeometry y="80" width="160" height="26" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="zkfFHV4jXpPFQw0GAbJ--4" value="" style="line;html=1;strokeWidth=1;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;" parent="zkfFHV4jXpPFQw0GAbJ--0" vertex="1"> | ||
<mxGeometry y="106" width="160" height="8" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="zkfFHV4jXpPFQw0GAbJ--5" value="+ Persona () : void" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="zkfFHV4jXpPFQw0GAbJ--0" vertex="1"> | ||
<mxGeometry y="114" width="160" height="26" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="LGDchbH-AgcG0QJ6Ip-j-9" value="+ toString () : String" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="zkfFHV4jXpPFQw0GAbJ--0"> | ||
<mxGeometry y="140" width="160" height="26" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="LGDchbH-AgcG0QJ6Ip-j-1" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="zkfFHV4jXpPFQw0GAbJ--0"> | ||
<mxGeometry y="166" width="160" height="26" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="zkfFHV4jXpPFQw0GAbJ--6" value="JefeProyecto" style="swimlane;fontStyle=0;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeLast=0;collapsible=1;marginBottom=0;rounded=0;shadow=0;strokeWidth=1;" parent="WIyWlLk6GJQsqaUBKTNV-1" vertex="1"> | ||
<mxGeometry y="360" width="200" height="112" as="geometry"> | ||
<mxRectangle x="130" y="380" width="160" height="26" as="alternateBounds" /> | ||
</mxGeometry> | ||
</mxCell> | ||
<mxCell id="zkfFHV4jXpPFQw0GAbJ--7" value="- area" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="zkfFHV4jXpPFQw0GAbJ--6" vertex="1"> | ||
<mxGeometry y="26" width="200" height="26" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="zkfFHV4jXpPFQw0GAbJ--9" value="" style="line;html=1;strokeWidth=1;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;" parent="zkfFHV4jXpPFQw0GAbJ--6" vertex="1"> | ||
<mxGeometry y="52" width="200" height="8" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="LGDchbH-AgcG0QJ6Ip-j-10" value="+ Persona () : void" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="zkfFHV4jXpPFQw0GAbJ--6"> | ||
<mxGeometry y="60" width="200" height="26" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="LGDchbH-AgcG0QJ6Ip-j-11" value="+ toString () : String" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="zkfFHV4jXpPFQw0GAbJ--6"> | ||
<mxGeometry y="86" width="200" height="26" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="zkfFHV4jXpPFQw0GAbJ--12" value="" style="endArrow=block;endSize=10;endFill=0;shadow=0;strokeWidth=1;rounded=0;curved=0;edgeStyle=elbowEdgeStyle;elbow=vertical;" parent="WIyWlLk6GJQsqaUBKTNV-1" source="zkfFHV4jXpPFQw0GAbJ--6" target="zkfFHV4jXpPFQw0GAbJ--0" edge="1"> | ||
<mxGeometry width="160" relative="1" as="geometry"> | ||
<mxPoint x="200" y="203" as="sourcePoint" /> | ||
<mxPoint x="200" y="203" as="targetPoint" /> | ||
</mxGeometry> | ||
</mxCell> | ||
<mxCell id="zkfFHV4jXpPFQw0GAbJ--13" value="Programador" style="swimlane;fontStyle=0;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeLast=0;collapsible=1;marginBottom=0;rounded=0;shadow=0;strokeWidth=1;" parent="WIyWlLk6GJQsqaUBKTNV-1" vertex="1"> | ||
<mxGeometry x="440" y="360" width="210" height="112" as="geometry"> | ||
<mxRectangle x="340" y="380" width="170" height="26" as="alternateBounds" /> | ||
</mxGeometry> | ||
</mxCell> | ||
<mxCell id="zkfFHV4jXpPFQw0GAbJ--14" value="- lenguaje" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="zkfFHV4jXpPFQw0GAbJ--13" vertex="1"> | ||
<mxGeometry y="26" width="210" height="26" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="zkfFHV4jXpPFQw0GAbJ--15" value="" style="line;html=1;strokeWidth=1;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;" parent="zkfFHV4jXpPFQw0GAbJ--13" vertex="1"> | ||
<mxGeometry y="52" width="210" height="8" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="LGDchbH-AgcG0QJ6Ip-j-12" value="+ Persona () : void" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="zkfFHV4jXpPFQw0GAbJ--13"> | ||
<mxGeometry y="60" width="210" height="26" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="LGDchbH-AgcG0QJ6Ip-j-13" value="+ toString () : String" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="zkfFHV4jXpPFQw0GAbJ--13"> | ||
<mxGeometry y="86" width="210" height="26" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="zkfFHV4jXpPFQw0GAbJ--16" value="" style="endArrow=block;endSize=10;endFill=0;shadow=0;strokeWidth=1;rounded=0;curved=0;edgeStyle=elbowEdgeStyle;elbow=vertical;" parent="WIyWlLk6GJQsqaUBKTNV-1" source="zkfFHV4jXpPFQw0GAbJ--13" target="zkfFHV4jXpPFQw0GAbJ--0" edge="1"> | ||
<mxGeometry width="160" relative="1" as="geometry"> | ||
<mxPoint x="210" y="373" as="sourcePoint" /> | ||
<mxPoint x="310" y="271" as="targetPoint" /> | ||
</mxGeometry> | ||
</mxCell> | ||
<mxCell id="zkfFHV4jXpPFQw0GAbJ--17" value="Oficina" style="swimlane;fontStyle=0;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeLast=0;collapsible=1;marginBottom=0;rounded=0;shadow=0;strokeWidth=1;" parent="WIyWlLk6GJQsqaUBKTNV-1" vertex="1"> | ||
<mxGeometry x="160" y="550" width="310" height="170" as="geometry"> | ||
<mxRectangle x="550" y="140" width="160" height="26" as="alternateBounds" /> | ||
</mxGeometry> | ||
</mxCell> | ||
<mxCell id="zkfFHV4jXpPFQw0GAbJ--18" value="- cantidadPuesto: int" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" parent="zkfFHV4jXpPFQw0GAbJ--17" vertex="1"> | ||
<mxGeometry y="26" width="310" height="26" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="zkfFHV4jXpPFQw0GAbJ--19" value="- jefeProyecto: JefeProyecto" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rounded=0;shadow=0;html=0;" parent="zkfFHV4jXpPFQw0GAbJ--17" vertex="1"> | ||
<mxGeometry y="52" width="310" height="26" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="zkfFHV4jXpPFQw0GAbJ--20" value="- programador: Programador" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rounded=0;shadow=0;html=0;" parent="zkfFHV4jXpPFQw0GAbJ--17" vertex="1"> | ||
<mxGeometry y="78" width="310" height="26" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="zkfFHV4jXpPFQw0GAbJ--23" value="" style="line;html=1;strokeWidth=1;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;" parent="zkfFHV4jXpPFQw0GAbJ--17" vertex="1"> | ||
<mxGeometry y="104" width="310" height="8" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="LGDchbH-AgcG0QJ6Ip-j-14" value="+ Persona () : void" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="zkfFHV4jXpPFQw0GAbJ--17"> | ||
<mxGeometry y="112" width="310" height="26" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="LGDchbH-AgcG0QJ6Ip-j-15" value="+ toString () : String" style="text;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="zkfFHV4jXpPFQw0GAbJ--17"> | ||
<mxGeometry y="138" width="310" height="26" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="LGDchbH-AgcG0QJ6Ip-j-20" value="Relation" style="endArrow=open;html=1;endSize=12;startArrow=diamondThin;startSize=14;startFill=0;edgeStyle=orthogonalEdgeStyle;rounded=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="zkfFHV4jXpPFQw0GAbJ--20" target="zkfFHV4jXpPFQw0GAbJ--14"> | ||
<mxGeometry relative="1" as="geometry"> | ||
<mxPoint x="540" y="630" as="sourcePoint" /> | ||
<mxPoint x="700" y="630" as="targetPoint" /> | ||
<Array as="points"> | ||
<mxPoint x="680" y="641" /> | ||
<mxPoint x="680" y="399" /> | ||
</Array> | ||
</mxGeometry> | ||
</mxCell> | ||
<mxCell id="LGDchbH-AgcG0QJ6Ip-j-21" value="0..n" style="edgeLabel;resizable=0;html=1;align=left;verticalAlign=top;" connectable="0" vertex="1" parent="LGDchbH-AgcG0QJ6Ip-j-20"> | ||
<mxGeometry x="-1" relative="1" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="LGDchbH-AgcG0QJ6Ip-j-22" value="1" style="edgeLabel;resizable=0;html=1;align=right;verticalAlign=top;" connectable="0" vertex="1" parent="LGDchbH-AgcG0QJ6Ip-j-20"> | ||
<mxGeometry x="1" relative="1" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="LGDchbH-AgcG0QJ6Ip-j-24" value="1" style="endArrow=open;html=1;endSize=12;startArrow=diamondThin;startSize=14;startFill=0;edgeStyle=orthogonalEdgeStyle;align=left;verticalAlign=bottom;rounded=0;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="zkfFHV4jXpPFQw0GAbJ--19" target="zkfFHV4jXpPFQw0GAbJ--7"> | ||
<mxGeometry x="-1" y="3" relative="1" as="geometry"> | ||
<mxPoint x="330" y="380" as="sourcePoint" /> | ||
<mxPoint x="490" y="380" as="targetPoint" /> | ||
<Array as="points"> | ||
<mxPoint x="-40" y="615" /> | ||
<mxPoint x="-40" y="399" /> | ||
</Array> | ||
</mxGeometry> | ||
</mxCell> | ||
</root> | ||
</mxGraphModel> | ||
</diagram> | ||
</mxfile> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package D21; | ||
|
||
public class Persona { | ||
private String rut; | ||
private String nombre; | ||
private int edad; | ||
private String direccion; | ||
|
||
public Persona(String rut, String nombre, int edad, String direccion) { | ||
this.rut = rut; | ||
this.nombre = nombre; | ||
this.edad = edad; | ||
this.direccion = direccion; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "\nRUT: " + rut + ",\nNombre: " + nombre + ",\nEdad: " + edad + ",\nDirección: " + direccion; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package D21; | ||
|
||
public class Taxi extends Vehiculos { | ||
private int valorPasaje; | ||
|
||
public Taxi(String color, String patente, int cantidadAsientos, int stock, int valorPasaje) { | ||
super(color, patente, cantidadAsientos, stock); | ||
this.valorPasaje = valorPasaje; | ||
} | ||
|
||
public void pagarPasaje(int pasaje) { | ||
System.out.println("Pasaje pagado: " + pasaje); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return super.toString() + ", Valor Pasaje: " + valorPasaje; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package D21; | ||
import java.util.List; | ||
|
||
public class Tienda { | ||
private String nombreTienda; | ||
private List<Vendedor> vendedores; | ||
private List<Vehiculos> vehiculos; | ||
|
||
public Tienda(String nombreTienda, List<Vendedor> vendedores, List<Vehiculos> vehiculos) { | ||
this.nombreTienda = nombreTienda; | ||
this.vendedores = vendedores; | ||
this.vehiculos = vehiculos; | ||
} | ||
|
||
public int cantidadStock(Vehiculos vehiculo) { | ||
return vehiculo.getStock(); | ||
} | ||
|
||
public boolean venderVehiculo(Vehiculos vehiculo) { | ||
return vehiculo.reducirStock(); | ||
} | ||
|
||
private int totalVehiculosEnStock() { | ||
int total = 0; | ||
for (Vehiculos vehiculo : vehiculos) { | ||
total += vehiculo.getStock(); | ||
} | ||
return total; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "\nNombre Tienda: " + nombreTienda + | ||
",\nCantidad de Vendedores: " + vendedores.size() + | ||
",\nTotal de Vehículos en Stock: " + totalVehiculosEnStock(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package D21; | ||
|
||
public class Vehiculos { | ||
private String color; | ||
private String patente; | ||
private int cantidadAsientos; | ||
private int stock; | ||
|
||
public Vehiculos(String color, String patente, int cantidadAsientos, int stock) { | ||
this.color = color; | ||
this.patente = patente; | ||
this.cantidadAsientos = cantidadAsientos; | ||
this.stock = stock; | ||
} | ||
|
||
public int getStock() { | ||
return stock; | ||
} | ||
|
||
public boolean reducirStock() { | ||
if (stock > 0) { | ||
stock--; | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
public int asientosDisponibles() { | ||
return cantidadAsientos; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "\nColor: " + color + ",\nPatente: " + patente + ",\nAsientos: " + cantidadAsientos + ",\nStock: " + stock; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package D21; | ||
|
||
public class Vendedor extends Persona { | ||
public Vendedor(String rut, String nombre, int edad, String direccion) { | ||
super(rut, nombre, edad, direccion); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package D21; | ||
|
||
public class Venta { | ||
private Cliente cliente; | ||
private Vendedor vendedor; | ||
private Tienda tienda; | ||
private Vehiculos vehiculo; | ||
|
||
public Venta(Cliente cliente, Vendedor vendedor, Tienda tienda, Vehiculos vehiculo) { | ||
this.cliente = cliente; | ||
this.vendedor = vendedor; | ||
this.tienda = tienda; | ||
this.vehiculo = vehiculo; | ||
} | ||
|
||
public boolean realizarVenta() { | ||
if (tienda.venderVehiculo(vehiculo)) { | ||
System.out.println("\nVenta realizada: " + this); | ||
return true; | ||
} else { | ||
System.out.println("Venta fallida: no hay stock disponible para " + vehiculo); | ||
return false; | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "\nCliente: " + cliente + ",\nVendedor: " + vendedor + ",\nTienda: " + tienda + ",\nVehículo: " + vehiculo; | ||
} | ||
} | ||
|
Oops, something went wrong.