aplicacion abstract factory

54
UNIVERSIDAD CAPITÁN GENERAL GERARDO BARRIOS Parcial Práctico I Facultad de Ciencia y Tecnología Carrera: Ingeniería en Sistemas y Redes Computacionales Asignatura: Ingeniería de Software II Apellidos Nombres Código Navarro Canales Nelson Mauricio SMIS044008 Grupo: A Catedrático: Ing. Joaquín Eduardo Bolaños Amaya 16 de septiembre de 2010.

Upload: nelson-navarro

Post on 06-Apr-2015

86 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Aplicacion Abstract Factory

UNIVERSIDAD CAPITÁN GENERAL GERARDO BARRIOS

Parcial Práctico I

Facultad de Ciencia y Tecnología

Carrera: Ingeniería en Sistemas y Redes Computacionales

Asignatura: Ingeniería de Software II

Apellidos Nombres Código

Navarro Canales Nelson Mauricio SMIS044008

Grupo: A

Catedrático: Ing. Joaquín Eduardo Bolaños Amaya

16 de septiembre de 2010.

Page 2: Aplicacion Abstract Factory

1. DISEÑO DE LA SOLUCION

Page 3: Aplicacion Abstract Factory

1.1 BREVE EXPLICACION

FUNCIONAMIENTO DE LA APLICACIÓN:

Se trata de una venta de computadoras laptops llamada best buy, la tienda maneja 3 marcas: Dell,

Hp y Sony. Cada marca que la empresa maneja tiene 3 modelos, los modelos se identifican por su ultima

silaba donde indica el procesador, se trata de la nueva línea de procesadores que Intel lanzo para el año

2010. Entre las marcas hay diferencias en los modelos a parte del procesador, la cantidad y marca de

memoria de video, el precio y la cantidad de memoria RAM.

Se aplicó Abstract Factory, los comentarios en el código fuente detallaran más claramente cómo se

implementó el modelo.

El modelo singleton, se aprovechó en el obsequio que Best Buy está otorgando por cada compra.

Actualmente el obsequio puede ser un impresora, un mouse bluetooh o un book bag (mochila), el usuario

solo puede elegir uno de los obsequios, una vez agregado su regalo no podrá agregar otro, al menos que

decida retirar o cancelar el regalo, podrá elegir otro (en esa parte se borra la instancia singleton para poder

instanciar nuevamente), igual los comentarios en las líneas de código mostraran un mejor detalle de lo que

aquí brevemente se presentó.

Dudas a:

[email protected]

Page 4: Aplicacion Abstract Factory

2. CODIFICACION DE CADA CLASE.

2.1 CODIGO DE LAS CLASES VISUAL BASIC.

FABRICA ABSTRACTA

Imports System.Collections.Generic Imports System.Linq Imports System.Text 'CLASE GENERAL ABSTRACTA ENCARGADA DE COLOCAR PROCESADOR RESPECTIVO A LAS NOTEBOOKS. Public MustInherit Class Notebooki7 'CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION Public Sub New() End Sub 'DECLARACION DE VARIABLES: ' Las propiedades son de tipo protegidas para que puedan ser heredada por las clases de producto concreto finales cada marca. Protected micro As String ' METODO QUE ENSAMBLA EL PROCESADOR. Public Function seti7() As String Me.micro = "Intel Core i7, 6MB Cache Level3, 8 Nucleos, a 2.8 MHZ With turbo Booster TM" Return ":" & Me.micro End Function End Class

FABRICAS CONCRETAS

DELL

Imports System.Collections.Generic Imports System.Linq Imports System.Text 'INDICANDO QUE LA FABRICA CONCRETA HEREDA DE LA ABSTRACTA FA_Nbooks. Public Class FCDell Inherits FA_Nbooks 'CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION Public Sub New() End Sub 'SOBREESCRIBIENDO TODOS LOS METODOS HEREDADOS. CON OVERRIDES. Public Overrides Function configuari7() As String

Page 5: Aplicacion Abstract Factory

Me.modelo = "Dell Studio 15i7" Me.precio = "$1350.00" Me.ram = "6 GBS" Me.video = "Ati 1GB" 'Llamando al producto final Delli7. ''Creando instancia. Dim delli7 As New Delli7 'En la cadena que se regresa al final se llama el metodo que estable el procesador. Return "Modelo: " & Me.modelo & ", Su Precio: " & Me.precio & ", Su Memoria Ram: " & Me.ram & ", Su VideoCard: " & Me.video & ". Junto a su novedoso procesador de la linea 2010:" & delli7.seti7() End Function Public Overrides Function configuari5() As String Me.modelo = "Dell Studio 15i5" Me.precio = "$900.00" Me.ram = "4 GBS" Me.video = "Ati 512MB" Dim delli5 As New Delli5() 'En la cadena que se regresa al final se llama el metodo que estable el procesador. Return "Modelo: " & Me.modelo & ", Su Precio: " & Me.precio & ", Su Memoria Ram: " & Me.ram & ", Su VideoCard: " & Me.video & ". Junto a su novedoso procesador de la linea 2010:" & delli5.seti5() End Function Public Overrides Function configuari3() As String Me.modelo = "Dell Studio 15i3" Me.precio = "750.00" Me.ram = "3 GBS" Me.video = "Intel HD 64mb" Dim delli3 As New Delli3() 'En la cadena que se regresa al final se llama el metodo que estable el procesador. Return "Modelo: " & Me.modelo & ", Su Precio: " & Me.precio & ", Su Memoria Ram: " & Me.ram & ", Su VideoCard: " & Me.video & ". Junto a su novedoso procesador de la linea 2010:" & delli3.seti3() End Function End Class

HP

Imports System.Collections.Generic Imports System.Linq Imports System.Text 'INDICANDO QUE LA FABRICA CONCRETA HEREDA DE LA ABSTRACTA FA_Nbooks. Class FCHP Inherits FA_Nbooks

Page 6: Aplicacion Abstract Factory

'SOBREESCRIBIENDO TODOS LOS METODOS HEREDADOS. CON OVERRIDE. Public Overrides Function configuari7() As String Me.modelo = "HP Pavilion 406i7" Me.precio = "$1250.00" Me.ram = "4 GBS" Me.video = "Ati 512MB" Dim hpi7 As New HPi7 'En la cadena que se regresa al final se llama el metodo que estable el procesador. Return "Modelo: " & Me.modelo & ", Su Precio: " & Me.precio & ", Su Memoria Ram: " & Me.ram & ", Su VideoCard: " & Me.video & ". Junto a su novedoso procesador de la linea 2010:" & hpi7.seti7() End Function Public Overrides Function configuari5() As String Me.modelo = "HP Pavilion 344i5" Me.precio = "$800.00" Me.ram = "4 GBS" Me.video = "Ati 256MB" Dim hpi5 As New HPi5 'En la cadena que se regresa al final se llama el metodo que estable el procesador. Return "Modelo: " & Me.modelo & ", Su Precio: " & Me.precio & ", Su Memoria Ram: " & Me.ram & ", Su VideoCard: " & Me.video & ". Junto a su novedoso procesador de la linea 2010:" & hpi5.seti5() End Function Public Overrides Function configuari3() As String Me.modelo = "HP Pavilion 276i3" Me.precio = "$650.00" Me.ram = "2 GBS" Me.video = "Intel HD 32mb" Dim hpi3 As New HPi3 'En la cadena que se regresa al final se llama el metodo que estable el procesador. Return "Modelo: " & Me.modelo & ", Su Precio: " & Me.precio & ", Su Memoria Ram: " & Me.ram & ", Su VideoCard: " & Me.video & ". Junto a su novedoso procesador de la linea 2010:" & hpi3.seti3() End Function End Class

SONY

Imports System.Collections.Generic Imports System.Linq Imports System.Text 'INDICANDO QUE LA FABRICA CONCRETA HEREDA DE LA ABSTRACTA FA_Nbooks. Class FCSony Inherits FA_Nbooks

Page 7: Aplicacion Abstract Factory

'SOBREESCRIBIENDO TODOS LOS METODOS HEREDADOS. CON OVERRIDE. Public Overrides Function configuari7() As String Me.modelo = "Sony Vaio E99i7" Me.precio = "$1200.00" Me.ram = "6 GBS" Me.video = "Nvidia 512MB" Dim sonyi7 As New Sonyi7 'En la cadena que se regresa al final se llama el metodo que estable el procesador. Return "Modelo: " & Me.modelo & ", Su Precio: " & Me.precio & ", Su Memoria Ram: " & Me.ram & ", Su VideoCard: " & Me.video & ". Junto a su novedoso procesador de la linea 2010:" & sonyi7.seti7() End Function Public Overrides Function configuari5() As String Me.modelo = "Sony Vaio E80i5" Me.precio = "$855.00" Me.ram = "3 GBS" Me.video = "Nvidia 256MB" Dim sonyi5 As New Sonyi5 'En la cadena que se regresa al final se llama el metodo que estable el procesador. Return "Modelo: " & Me.modelo & ", Su Precio: " & Me.precio & ", Su Memoria Ram: " & Me.ram & ", Su VideoCard: " & Me.video & ". Junto a su novedoso procesador de la linea 2010:" & sonyi5.seti5() End Function Public Overrides Function configuari3() As String Me.modelo = "Sony Vaio E70i3" Me.precio = "$730.00" Me.ram = "3 GBS" Me.video = "Intel HD 128mb" Dim sonyi3 As New Sonyi3 'En la cadena que se regresa al final se llama el metodo que estable el procesador. Return "Modelo: " & Me.modelo & ", Su Precio: " & Me.precio & ", Su Memoria Ram: " & Me.ram & ", Su VideoCard: " & Me.video & ". Junto a su novedoso procesador de la linea 2010:" & sonyi3.seti3() End Function End Class

PRODUCTOS ABSTRACTOS.

NOTEBOOKS i7

Imports System.Collections.Generic Imports System.Linq Imports System.Text

Page 8: Aplicacion Abstract Factory

'CLASE GENERAL ABSTRACTA ENCARGADA DE COLOCAR PROCESADOR RESPECTIVO A LAS NOTEBOOKS. Public MustInherit Class Notebooki7 'CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION Public Sub New() End Sub 'DECLARACION DE VARIABLES: ' Las propiedades son de tipo protegidas para que puedan ser heredada por las clases de producto concreto finales cada marca. Protected micro As String ' METODO QUE ENSAMBLA EL PROCESADOR. Public Function seti7() As String Me.micro = "Intel Core i7, 6MB Cache Level3, 8 Nucleos, a 2.8 MHZ With turbo Booster TM" Return ":" & Me.micro End Function End Class

NOTEBOOKS i5

'CLASE GENERAL ABSTRACTA ENCARGADA DE COLOCAR PROCESADOR RESPECTIVO A LAS NOTEBOOKS. Public MustInherit Class Notebooki5 'CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION Public Sub New() End Sub 'DECLARACION DE VARIABLES: ' Las propiedades son de tipo protegidas para que puedan ser heredada por las clases de producto concreto finales cada marca. Protected micro As String ' METODO QUE ENSAMBLA EL PROCESADOR. Public Function seti5() As String Me.micro = "Intel Core i5, 3MB Cache Level3, 4 Nucleos, a 2.1 MHZ With turbo Booster TM" Return ":" & Me.micro End Function End Class

NOTEBOOKS i3

'CLASE GENERAL ABSTRACTA ENCARGADA DE COLOCAR PROCESADOR RESPECTIVO A LAS NOTEBOOKS. Public MustInherit Class Notebooki3

Page 9: Aplicacion Abstract Factory

'CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION Public Sub New() End Sub 'DECLARACION DE VARIABLES: ' Las propiedades son de tipo protegidas para que puedan ser heredada por las clases de producto concreto finales cada marca. Protected micro As String ' METODO QUE ENSAMBLA EL PROCESADOR. Public Function seti3() As String Me.micro = "Intel Core i3, 3MB Cache Level3, 4 Nucleos, a 2.0 MHZ" Return ":" & Me.micro End Function End Class

CLASES PRODUCTOS CONCRETOS O FINALES.

DELL’s

Public Class Delli7 Inherits Notebooki7 'Dell i7 hereda de la abstracta Notebook i7. 'CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION Public Sub New() End Sub End Class Public Class Delli5 Inherits Notebooki5 'Dell i5 hereda de la abstracta Notebook i5. 'CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION Public Sub New() End Sub End Class Public Class Delli3 Inherits Notebooki3 'Dell i3 hereda de la abstracta Notebook i3. 'CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION Public Sub New() End Sub End Class

HP’s

Public Class HPi7

Page 10: Aplicacion Abstract Factory

Inherits Notebooki7 'Dell i5 hereda de la abstracta Notebook i5. 'CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION Public Sub New() End Sub End Class

Public Class HPi5 Inherits Notebooki5 'Dell i5 hereda de la abstracta Notebook i5. 'CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION Public Sub New() End Sub End Class Public Class HPi3 Inherits Notebooki3 'Dell i5 hereda de la abstracta Notebook i5. 'CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION Public Sub New() End Sub End Class

SONY’s

Public Class Sonyi7 Inherits Notebooki7 'Dell i7 hereda de la abstracta Notebook i7. 'CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION Public Sub New() End Sub End Class Public Class Sonyi5 Inherits Notebooki5 'Dell i5 hereda de la abstracta Notebook i5 'CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION Public Sub New() End Sub End Class Public Class Sonyi3 Inherits Notebooki3 'Dell i3 hereda de la abstracta Notebook i3. 'CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION Public Sub New() End Sub End Class

Page 11: Aplicacion Abstract Factory

CLASE REGALO DONDE SE IMPLEMENTO SINGLETON.

Imports System.Collections.Generic Imports System.Linq Imports System.Text Class Regalo ' Declaramos de acuerdo al patrón Singleton, la variable instancia.El modificador static sirve permite trabajar con la propiedad instancia desde dentro de la clase, aun sin haber instanciado la clase ok. Private Shared instancia As Regalo 'CONSTRUCTOR declarado segun el diseño singleton como privado. Private Sub New() End Sub Public Shared Function getInstancia() As Regalo ' Este es el método que devuelve la única instancia, Se evalúa la condición, si no existe instancia la crea. If instancia Is Nothing Then instancia = New Regalo End If ' Devuelve la instancia. Si existe entonces regresara la existente. Return instancia End Function Public Function establecerRegalo(ByVal regalo As String) As String ' Método que recibira el regalo y devolvera el regalo. Return regalo End Function End Class

2.2 CODIGO DE LAS CLASES C SHARP

FABRICA ABSTRACTA

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace parcialPracticoI { ///ESTA ES LA CLASE FABRICA ABSTRACTA public abstract class FA_Nbooks ///indica que es abstracta { //CONSTRUCTOR.

Page 12: Aplicacion Abstract Factory

public FA_Nbooks() { } //DECLARACION DE VARIABLES: // Las propiedades son de tipo protegidas para que puedan ser heredada por las clases fabricas concretas de cada marca. protected String video; protected String ram; protected String modelo; protected String precio; // METODOS QUE SE SOBREESCRIBIRAN POR LAS FABRICAS CONCRETAS. //indicandolo con abstract public abstract String configuari7(); public abstract String configuari5(); public abstract String configuari3(); } }

FABRICAS CONCRETAS

DELL

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace parcialPracticoI { //INDICANDO QUE LA FABRICA CONCRETA HEREDA DE LA ABSTRACTA FA_Nbooks. public class FCDell:FA_Nbooks { //CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION public FCDell(){} //SOBREESCRIBIENDO TODOS LOS METODOS HEREDADOS. CON OVERRIDE. public override String configuari7() { this.modelo = "Dell Studio 15i7"; this.precio = "$1350.00"; this.ram = "6 GBS"; this.video="Ati 1GB"; ///Llamando al producto final Delli7. ///Creando instancia. Delli7 delli7 = new Delli7(); //En la cadena que se regresa al final se llama el metodo que estable el procesador.

Page 13: Aplicacion Abstract Factory

return "Modelo: " + this.modelo + ", Su Precio: " + this.precio + ", Su Memoria Ram: " + this.ram + ", Su VideoCard: " + this.video + ". Junto a su novedoso procesador de la linea 2010:" + delli7.seti7(); } public override String configuari5() { this.modelo = "Dell Studio 15i5"; this.precio = "$900.00"; this.ram = "4 GBS"; this.video = "Ati 512MB"; Delli5 delli5 = new Delli5(); //En la cadena que se regresa al final se llama el metodo que estable el procesador. return "Modelo: " + this.modelo + ", Su Precio: " + this.precio + ", Su Memoria Ram: " + this.ram + ", Su VideoCard: " + this.video + ". Junto a su novedoso procesador de la linea 2010:" + delli5.seti5(); } public override String configuari3() { this.modelo = "Dell Studio 15i3"; this.precio = "750.00"; this.ram = "3 GBS"; this.video = "Intel HD 64mb"; Delli3 delli3 = new Delli3(); //En la cadena que se regresa al final se llama el metodo que estable el procesador. return "Modelo: " + this.modelo + ", Su Precio: " + this.precio + ", Su Memoria Ram: " + this.ram + ", Su VideoCard: " + this.video + ". Junto a su novedoso procesador de la linea 2010:" + delli3.seti3(); } } }

HP

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace parcialPracticoI {

Page 14: Aplicacion Abstract Factory

//INDICANDO QUE LA FABRICA CONCRETA HEREDA DE LA ABSTRACTA FA_Nbooks. class FCHP : FA_Nbooks { //SOBREESCRIBIENDO TODOS LOS METODOS HEREDADOS. CON OVERRIDE. public override String configuari7() { this.modelo = "HP Pavilion 406i7"; this.precio = "$1250.00"; this.ram = "4 GBS"; this.video = "Ati 512MB"; HPi7 hpi7 = new HPi7(); //En la cadena que se regresa al final se llama el metodo que estable el procesador. return "Modelo: " + this.modelo + ", Su Precio: " + this.precio + ", Su Memoria Ram: " + this.ram + ", Su VideoCard: " + this.video + ". Junto a su novedoso procesador de la linea 2010:" + hpi7.seti7(); } public override String configuari5() { this.modelo = "HP Pavilion 344i5"; this.precio = "$800.00"; this.ram = "4 GBS"; this.video = "Ati 256MB"; HPi5 hpi5 = new HPi5(); //En la cadena que se regresa al final se llama el metodo que estable el procesador. return "Modelo: " + this.modelo + ", Su Precio: " + this.precio + ", Su Memoria Ram: " + this.ram + ", Su VideoCard: " + this.video + ". Junto a su novedoso procesador de la linea 2010:" + hpi5.seti5(); } public override String configuari3() { this.modelo = "HP Pavilion 276i3"; this.precio = "$650.00"; this.ram = "2 GBS"; this.video = "Intel HD 32mb"; HPi3 hpi3 = new HPi3(); //En la cadena que se regresa al final se llama el metodo que estable el procesador. return "Modelo: " + this.modelo + ", Su Precio: " + this.precio + ", Su Memoria Ram: " + this.ram + ", Su VideoCard: " + this.video + ". Junto a su novedoso procesador de la linea 2010:" + hpi3.seti3(); } } }

Page 15: Aplicacion Abstract Factory

SONY

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace parcialPracticoI { //INDICANDO QUE LA FABRICA CONCRETA HEREDA DE LA ABSTRACTA FA_Nbooks. class FCSony : FA_Nbooks { //SOBREESCRIBIENDO TODOS LOS METODOS HEREDADOS. CON OVERRIDE. public override String configuari7() { this.modelo = "Sony Vaio E99i7"; this.precio = "$1200.00"; this.ram = "6 GBS"; this.video = "Nvidia 512MB"; Sonyi7 sonyi7 = new Sonyi7(); //En la cadena que se regresa al final se llama el metodo que estable el procesador. return "Modelo: " + this.modelo + ", Su Precio: " + this.precio + ", Su Memoria Ram: " + this.ram + ", Su VideoCard: " + this.video + ". Junto a su novedoso procesador de la linea 2010:" + sonyi7.seti7(); } public override String configuari5() { this.modelo = "Sony Vaio E80i5"; this.precio = "$855.00"; this.ram = "3 GBS"; this.video = "Nvidia 256MB"; Sonyi5 sonyi5 = new Sonyi5(); //En la cadena que se regresa al final se llama el metodo que estable el procesador. return "Modelo: " + this.modelo + ", Su Precio: " + this.precio + ", Su Memoria Ram: " + this.ram + ", Su VideoCard: " + this.video + ". Junto a su novedoso procesador de la linea 2010:" + sonyi5.seti5(); } public override String configuari3() { this.modelo = "Sony Vaio E70i3"; this.precio = "$730.00"; this.ram = "3 GBS"; this.video = "Intel HD 128mb"; Sonyi3 sonyi3 = new Sonyi3(); //En la cadena que se regresa al final se llama el metodo que estable el procesador. return "Modelo: " + this.modelo + ", Su Precio: " + this.precio + ", Su Memoria Ram: " + this.ram + ", Su VideoCard: " + this.video + ". Junto a su novedoso procesador de la linea 2010:" + sonyi3.seti3();

Page 16: Aplicacion Abstract Factory

} } }

PRODUCTOS ABSTRACTOS.

NOTEBOOKS i7

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace parcialPracticoI { //CLASE GENERAL ABSTRACTA ENCARGADA DE COLOCAR PROCESADOR RESPECTIVO A LAS NOTEBOOKS. public abstract class Notebooki7 { //CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION public Notebooki7() { } //DECLARACION DE VARIABLES: // Las propiedades son de tipo protegidas para que puedan ser heredada por las clases de producto concreto finales cada marca. protected String micro; // METODO QUE ENSAMBLA EL PROCESADOR. public String seti7() { this.micro = "Intel Core i7, 6MB Cache Level3, 8 Nucleos, a 2.8 MHZ With turbo Booster TM"; return ":" + this.micro; } } }

NOTEBOOKS i5

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace parcialPracticoI { //CLASE GENERAL ABSTRACTA ENCARGADA DE COLOCAR PROCESADOR RESPECTIVO A LAS NOTEBOOKS.

Page 17: Aplicacion Abstract Factory

public abstract class Notebooki5 { //CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION public Notebooki5() { } //DECLARACION DE VARIABLES: // Las propiedades son de tipo protegidas para que puedan ser heredada por las clases de producto concreto finales cada marca. protected String micro; // METODO QUE ENSAMBLA EL PROCESADOR. public String seti5() { this.micro = "Intel Core i5, 3MB Cache Level3, 4 Nucleos, a 2.1 MHZ With turbo Booster TM"; return ":" + this.micro; } } }

NOTEBOOKS i3

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace parcialPracticoI { //CLASE GENERAL ABSTRACTA ENCARGADA DE COLOCAR PROCESADOR RESPECTIVO A LAS NOTEBOOKS. public abstract class Notebooki3 { //CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION public Notebooki3() { } //DECLARACION DE VARIABLES: // Las propiedades son de tipo protegidas para que puedan ser heredada por las clases de producto concreto finales cada marca. protected String micro; // METODO QUE ENSAMBLA EL PROCESADOR. public String seti3() { this.micro = "Intel Core i3, 3MB Cache Level3, 4 Nucleos, a 2.0 MHZ"; return ":" + this.micro; }

Page 18: Aplicacion Abstract Factory

} }

CLASES PRODUCTOS CONCRETOS O FINALES.

DELL’s

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace parcialPracticoI { public class Delli7 : Notebooki7 //Dell i7 hereda de la abstracta Notebook i7. { //CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION public Delli7() { } } } using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace parcialPracticoI { public class Delli5 : Notebooki5 //Dell i5 hereda de la abstracta Notebook i5. { //CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION public Delli5() { } } } using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace parcialPracticoI { public class Delli3 : Notebooki3 //Dell i3 hereda de la abstracta Notebook i3. { //CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION public Delli3() { } } }

Page 19: Aplicacion Abstract Factory

HP’s

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace parcialPracticoI { public class HPi7 : Notebooki7 //HP i7 hereda de la abstracta Notebook i7. { //CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION public HPi7() { } } } using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace parcialPracticoI { public class HPi5 : Notebooki5 //HP i5 hereda de la abstracta Notebook i5. { //CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION public HPi5() { } } } using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace parcialPracticoI { public class HPi3 : Notebooki3 //HP i3 hereda de la abstracta Notebook i3. { //CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION public HPi3() { } } }

SONY’s

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace parcialPracticoI

Page 20: Aplicacion Abstract Factory

{ public class Sonyi7 : Notebooki7 //Sony i7 hereda de la abstracta Notebook i7. { //CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION public Sonyi7() { } } } using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace parcialPracticoI { public class Sonyi5 : Notebooki5 //Sony i5 hereda de la abstracta Notebook i5. { //CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION public Sonyi5() { } } } using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace parcialPracticoI { public class Sonyi3 : Notebooki3 //Sony i3 hereda de la abstracta Notebook i3. { //CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION public Sonyi3() { } } }

CLASE REGALO DONDE SE IMPLEMENTO SINGLETON.

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace parcialPracticoI { class Regalo { // Declaramos de acuerdo al patrón Singleton, la variable instancia.El modificador static sirve permite trabajar con la propiedad instancia desde dentro de la clase, aun sin haber instanciado la clase ok. private static Regalo instancia; private Regalo()

Page 21: Aplicacion Abstract Factory

{ //CONSTRUCTOR declarado segun el diseño singleton como privado. } public static Regalo getInstancia() { // Este es el método que devuelve la única instancia, Se evalúa la condición, si no existe instancia la crea. if (instancia == null) { instancia = new Regalo(); } // Devuelve la instancia. Si existe entonces regresara la existente. return instancia; } public string establecerRegalo(String regalo) { // Método que recibira el regalo y devolvera el regalo. return regalo; } } }

2.3 CODIGO DE LAS CLASES PHP

FABRICA ABSTRACTA

///ESTA ES LA CLASE FABRICA ABSTRACTA

abstract class FA_Nbooks ///indica que es abstracta

{

//CONSTRUCTOR.

function __construct()

{

}

//DECLARACION DE VARIABLES:

Page 22: Aplicacion Abstract Factory

// Las propiedades son de tipo protegidas para que puedan ser heredada por las clases

fabricas concretas de cada marca.

protected $video;

protected $ram;

protected $modelo;

protected $precio;

// METODOS QUE SE SOBREESCRIBIRAN POR LAS FABRICAS CONCRETAS.

//indicandolo con abstract

public abstract function configuari7();

public abstract function configuari5();

public abstract function configuari3();

}

FABRICAS CONCRETAS

DELL

//INDICANDO QUE LA FABRICA CONCRETA HEREDA DE LA ABSTRACTA FA_Nbooks.

class FCDell extends FA_Nbooks

{

//CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION

function __construct()

{

Page 23: Aplicacion Abstract Factory

}

//SOBREESCRIBIENDO TODOS LOS METODOS HEREDADOS.

public function configuari7()

{

$this->modelo = "Dell Studio 15i7";

$this->precio = "$1350.00";

$this->ram = "6 GBS";

$this->video="Ati 1GB";

///Llamando al producto final Delli7.

///Creando instancia.

$delli7 = new Delli7();

//En la cadena que se regresa al final se llama el metodo que estable el procesador.

return "Modelo: " . $this->modelo . ", Su Precio: " . $this->precio . ", Su Memoria Ram: " .

$this->ram . ", Su VideoCard: " . $this->video . ". Junto a su novedoso procesador de la linea

2010:" . $delli7->seti7();

}

public function configuari5()

{

$this->modelo = "Dell Studio 15i5";

$this->precio = "$900.00";

$this->ram = "4 GBS";

$this->video = "Ati 512MB";

Page 24: Aplicacion Abstract Factory

$delli5 = new Delli5();

//En la cadena que se regresa al final se llama el metodo que estable el procesador.

return "Modelo: " . $this->modelo . ", Su Precio: " . $this->precio . ", Su Memoria Ram:

" . $this->ram . ", Su VideoCard: " . $this->video . ". Junto a su novedoso procesador de la linea

2010:" . $delli5->seti5();

}

public function configuari3()

{

$this->modelo = "Dell Studio 15i3";

$this->precio = "750.00";

$this->ram = "3 GBS";

$this->video = "Intel HD 64mb";

$delli3 = new Delli3();

//En la cadena que se regresa al final se llama el metodo que estable el procesador.

return "Modelo: " . $this->modelo . ", Su Precio: " . $this->precio . ", Su Memoria Ram:

" . $this->ram . ", Su VideoCard: " . $this->video . ". Junto a su novedoso procesador de la linea

2010:" . $delli3->seti3();

}

}

Page 25: Aplicacion Abstract Factory

HP

//INDICANDO QUE LA FABRICA CONCRETA HEREDA DE LA ABSTRACTA FA_Nbooks.

class FCHP extends FA_Nbooks

{

//SOBREESCRIBIENDO TODOS LOS METODOS HEREDADOS.

public function configuari7()

{

$this->modelo = "HP Pavilion 406i7";

$this->precio = "$1250.00";

$this->ram = "4 GBS";

$this->video = "Ati 512MB";

$hpi7 = new HPi7();

//En la cadena que se regresa al final se llama el metodo que estable el procesador.

return "Modelo: " . $this->modelo . ", Su Precio: " . $this->precio . ", Su Memoria Ram: " . $this-

>ram . ", Su VideoCard: " . $this->video . ". Junto a su novedoso procesador de la linea 2010:" .

$hpi7->seti7();

}

public function configuari5()

{

$this->modelo = "HP Pavilion 344i5";

$this->precio = "$800.00";

$this->ram = "4 GBS";

Page 26: Aplicacion Abstract Factory

$this->video = "Ati 256MB";

$hpi5 = new HPi5();

//En la cadena que se regresa al final se llama el metodo que estable el procesador.

return "Modelo: " . $this->modelo . ", Su Precio: " . $this->precio . ", Su Memoria Ram: " . $this-

>ram . ", Su VideoCard: " . $this->video . ". Junto a su novedoso procesador de la linea 2010:" .

$hpi5->seti5();

}

public function configuari3()

{

$this->modelo = "HP Pavilion 276i3";

$this->precio = "$650.00";

$this->ram = "2 GBS";

$this->video = "Intel HD 32mb";

$hpi3 = new HPi3();

//En la cadena que se regresa al final se llama el metodo que estable el procesador.

return "Modelo: " . $this->modelo . ", Su Precio: " . $this->precio . ", Su Memoria Ram: " . $this-

>ram . ", Su VideoCard: " . $this->video . ". Junto a su novedoso procesador de la linea 2010:" .

$hpi3->seti3();

}

}

Page 27: Aplicacion Abstract Factory

SONY

//INDICANDO QUE LA FABRICA CONCRETA HEREDA DE LA ABSTRACTA FA_Nbooks.

class FCSony extends FA_Nbooks

{

//SOBREESCRIBIENDO TODOS LOS METODOS HEREDADOS.

public function configuari7()

{

$this->modelo = "Sony Vaio E99i7";

$this->precio = "$1200.00";

$this->ram = "6 GBS";

$this->video = "Nvidia 512MB";

$sonyi7 = new Sonyi7();

//En la cadena que se regresa al final se llama el metodo que estable el procesador.

return "Modelo: " . $this->modelo . ", Su Precio: " . $this->precio . ", Su Memoria Ram: " .

$this->ram . ", Su VideoCard: " . $this->video . ". Junto a su novedoso procesador de la linea

2010:" . $sonyi7->seti7();

}

public function configuari5()

{

$this->modelo = "Sony Vaio E80i5";

$this->precio = "$855.00";

$this->ram = "3 GBS";

Page 28: Aplicacion Abstract Factory

$this->video = "Nvidia 256MB";

$sonyi5 = new Sonyi5();

//En la cadena que se regresa al final se llama el metodo que estable el procesador.

return "Modelo: " . $this->modelo . ", Su Precio: " . $this->precio . ", Su Memoria Ram: " .

$this->ram . ", Su VideoCard: " . $this->video . ". Junto a su novedoso procesador de la linea

2010:" . $sonyi5->seti5();

}

public function configuari3()

{

$this->modelo = "Sony Vaio E70i3";

$this->precio = "$730.00";

$this->ram = "3 GBS";

$this->video = "Intel HD 128mb";

$sonyi3 = new Sonyi3();

//En la cadena que se regresa al final se llama el metodo que estable el procesador.

return "Modelo: " . $this->modelo . ", Su Precio: " . $this->precio . ", Su Memoria Ram: " .

$this->ram . ", Su VideoCard: " . $this->video . ". Junto a su novedoso procesador de la linea

2010:" . $sonyi3->seti3();

}

}

Page 29: Aplicacion Abstract Factory

PRODUCTOS ABSTRACTOS.

NOTEBOOKS i7

//CLASE GENERAL ABSTRACTA ENCARGADA DE COLOCAR PROCESADOR RESPECTIVO A LAS

NOTEBOOKS.

abstract class Notebooki7

{

//CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION

function __construct()

{

}

//DECLARACION DE VARIABLES:

// Las propiedades son de tipo protegidas para que puedan ser heredada por las clases de

producto concreto finales cada marca.

protected $micro;

// METODO QUE ENSAMBLA EL PROCESADOR.

public function seti7()

{

$this->micro = "Intel Core i7,

6MB Cache Level3, 8 Nucleos, a 2.8 MHZ With turbo Booster TM";

return ":" . $this->micro;

}

}

Page 30: Aplicacion Abstract Factory

NOTEBOOKS i5

//CLASE GENERAL ABSTRACTA ENCARGADA DE COLOCAR PROCESADOR RESPECTIVO A LAS

NOTEBOOKS.

abstract class Notebooki5

{

//CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION

function __construct() { }

//DECLARACION DE VARIABLES:

// Las propiedades son de tipo protegidas para que puedan ser heredada por las clases de

producto concreto finales cada marca.

protected $micro;

// METODO QUE ENSAMBLA EL PROCESADOR.

public function seti5()

{

$this->micro = "Intel Core i5, 3MB Cache Level3, 4 Nucleos, a 2.1 MHZ With turbo

Booster TM";

return ":" . $this->micro;

}

}

NOTEBOOKS i3

//CLASE GENERAL ABSTRACTA ENCARGADA DE COLOCAR PROCESADOR RESPECTIVO A LAS

NOTEBOOKS.

abstract class Notebooki3

{

Page 31: Aplicacion Abstract Factory

//CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION

function __construct() { }

//DECLARACION DE VARIABLES:

// Las propiedades son de tipo protegidas para que puedan ser heredada por las clases de

producto concreto finales cada marca.

protected $micro;

// METODO QUE ENSAMBLA EL PROCESADOR.

public function seti3()

{

$this->micro = "Intel Core i3, 3MB Cache Level3, 4 Nucleos, a 2.0 MHZ";

return ":" . $this->micro;

}

}

CLASES PRODUCTOS CONCRETOS O FINALES.

DELL’s

class Delli7 extends Notebooki7 //Dell i7 hereda de la abstracta Notebook i7.

{

Page 32: Aplicacion Abstract Factory

//CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION

function __construct() { }

}

class Delli5 extends Notebooki5 //Dell i5 hereda de la abstracta Notebook i5.

{

//CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION

function __construct() { }

}

class Delli3 extends Notebooki3 //Dell i3 hereda de la abstracta Notebook i3.

{

//CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION

function __construct() { }

}

HP’s

class HPi7 extends Notebooki7 //HP i7 hereda de la abstracta Notebook i7.

{

//CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION

function __construct() { }

}

class HPi5 extends Notebooki5 //HP i5 hereda de la abstracta Notebook i5.

{

//CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION

function __construct() { }

Page 33: Aplicacion Abstract Factory

}

class HPi3 extends Notebooki3 //HP i3 hereda de la abstracta Notebook i3.

{

//CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION

function __construct() { }

}

SONY’s

class Sonyi7 extends Notebooki7 //Sony i7 hereda de la abstracta Notebook i7.

{

//CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION

function __construct() { }

}

class Sonyi5 extends Notebooki5 //Sony i5 hereda de la abstracta Notebook i5.

{

//CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION

function __construct() { }

}

class Sonyi3 extends Notebooki3 //Sony i3 hereda de la abstracta Notebook i3.

{

//CONSTRUCTOR DECLARADO POR BUENAS PRACTICAS DE PROGRAMACION

function __construct() { }

}

Page 34: Aplicacion Abstract Factory

CLASE REGALO DONDE SE IMPLEMENTO SINGLETON.

class Regalo

{

// Declaramos de acuerdo al patrón Singleton, la variable instancia.El modificador static sirve

permite trabajar con la propiedad instancia desde dentro de la clase, aun sin haber instanciado

la clase ok.

private static $instancia;

private function __construct()

{

//CONSTRUCTOR declarado segun el diseño singleton como privado.

}

public static function getInstancia()

{

// Este es el método que devuelve la única instancia, Se evalúa la condición, si no existe

instancia la crea.

if(!isset(self::$instancia))

{

self::$instancia = new Regalo();

}

// Devuelve la instancia. Si existe entonces regresara la existente.

return self::$instancia;

}

Page 35: Aplicacion Abstract Factory

public function establecerRegalo($regalo)

{

// Método que recibira el regalo y devolvera el regalo.

return $regalo;

}

}

Page 36: Aplicacion Abstract Factory

3. CODIGO DEL CLIENTE.

3.1 CLIENTE VISUAL BASIC

Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private c As Regalo ' La instancia de Regalo privada como lo establece el modelo. Private Sub button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button3.Click ''SI EL CLIENTE PIDE UNA DELL If (Me.comboBox1.Text = "Dell Studio i7") Then 'Creando una instancia de la fabrica Concreta Dell Dim dell As New FCDell textBox1.Text = dell.configuari7() & " y por su compra usted recibira tambien: " & Me.textBox2.Text End If If (Me.comboBox1.Text = "Dell Studio i5") Then 'Creando una instancia de la fabrica Concreta Dell Dim dell As New FCDell textBox1.Text = dell.configuari5() & " y por su compra usted recibira tambien: " & Me.textBox2.Text End If If (Me.comboBox1.Text = "Dell Studio i3") Then 'Creando una instancia de la fabrica Concreta Dell Dim dell As New FCDell textBox1.Text = dell.configuari3() & " y por su compra usted recibira tambien: " & Me.textBox2.Text End If ''SI EL CLIENTE PIDE UNA HP If (Me.comboBox1.Text = "HP Pavilion i7") Then 'Creando una instancia de la fabrica Concreta HP Dim hp As New FCHP textBox1.Text = hp.configuari7() & " y por su compra usted recibira tambien: " & Me.textBox2.Text End If If (Me.comboBox1.Text = "HP Pavilion i5") Then 'Creando una instancia de la fabrica Concreta HP Dim hp As New FCHP textBox1.Text = hp.configuari5() & " y por su compra usted recibira tambien: " & Me.textBox2.Text End If

Page 37: Aplicacion Abstract Factory

If (Me.comboBox1.Text = "HP Pavilion i3") Then 'Creando una instancia de la fabrica Concreta HP Dim hp As New FCHP textBox1.Text = hp.configuari3() & " y por su compra usted recibira tambien: " & Me.textBox2.Text End If ''SI EL CLIENTE PIDE UNA SONY If (Me.comboBox1.Text = "Sony Vaio i7") Then 'Creando una instancia de la fabrica Concreta HP Dim sony As New FCSony textBox1.Text = sony.configuari7() & " y por su compra usted recibira tambien: " & Me.textBox2.Text End If If (Me.comboBox1.Text = "Sony Vaio i5") Then 'Creando una instancia de la fabrica Concreta HP Dim sony As New FCSony textBox1.Text = sony.configuari5() & " y por su compra usted recibira tambien: " & Me.textBox2.Text End If If (Me.comboBox1.Text = "Sony Vaio i5") Then 'Creando una instancia de la fabrica Concreta HP Dim sony As New FCSony textBox1.Text = sony.configuari5() & " y por su compra usted recibira tambien: " & Me.textBox2.Text End If End Sub Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click If c Is Nothing Then ' Si c no se ha creado ' Crear instancia única. c = Regalo.getInstancia() textBox2.Text = c.establecerRegalo(Me.comboBox2.Text) End If End Sub Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click ' Crear borra la instancia c, por si el cliente decide cambiar de opinión en su regalo. c = Nothing Me.textBox2.Text = ""

Page 38: Aplicacion Abstract Factory

End Sub End Class

3.2 CLIENTE VISUAL C SHARP

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace parcialPracticoI { public partial class Form1 : Form { private Regalo c; // La instancia de Regalo privada como lo establece el modelo. public Form1() { InitializeComponent(); } private void label4_Click(object sender, EventArgs e) { } private void button3_Click(object sender, EventArgs e) { ///ESTRUCTURAS DE DECISION PARA PEDIDOS DE LA MARCA DELL if (this.comboBox1.Text == "Dell Studio i7") { //Creando una instancia de la fabrica Concreta Dell FCDell dell = new FCDell(); textBox1.Text = dell.configuari7()+" y por su compra usted recibira tambien: "+ this.textBox2.Text; } if (this.comboBox1.Text == "Dell Studio i5") { //Creando una instancia de la fabrica Concreta Dell FCDell dell = new FCDell(); textBox1.Text = dell.configuari5() + " y por su compra usted recibira tambien: " + this.textBox2.Text; } if (this.comboBox1.Text == "Dell Studio i3") { //Creando una instancia de la fabrica Concreta Dell FCDell dell = new FCDell(); textBox1.Text = dell.configuari3() + " y por su compra usted recibira tambien: " + this.textBox2.Text;

Page 39: Aplicacion Abstract Factory

} ///ESTRUCTURAS DE DECISION PARA PEDIDOS DE LA MARCA HP if (this.comboBox1.Text == "HP Pavilion i7") { //Creando una instancia de la fabrica Concreta Dell FCHP hp = new FCHP(); textBox1.Text = hp.configuari7() + " y por su compra usted recibira tambien: " + this.textBox2.Text; } if (this.comboBox1.Text == "HP Pavilion i5") { //Creando una instancia de la fabrica Concreta Dell FCHP hp = new FCHP(); textBox1.Text = hp.configuari5() + " y por su compra usted recibira tambien: " + this.textBox2.Text; } if (this.comboBox1.Text == "HP Pavilion i3") { //Creando una instancia de la fabrica Concreta Dell FCHP hp = new FCHP(); textBox1.Text = hp.configuari3() + " y por su compra usted recibira tambien: " + this.textBox2.Text; } ///ESTRUCTURAS DE DECISION PARA PEDIDOS DE LA MARCA SONY if (this.comboBox1.Text == "Sony Vaio i7") { //Creando una instancia de la fabrica Concreta Dell FCSony sony = new FCSony(); textBox1.Text = sony.configuari7() + " y por su compra usted recibira tambien: " + this.textBox2.Text; } if (this.comboBox1.Text == "Sony Vaio i5") { //Creando una instancia de la fabrica Concreta Dell FCSony sony = new FCSony(); textBox1.Text = sony.configuari5() + " y por su compra usted recibira tambien: " + this.textBox2.Text; } if (this.comboBox1.Text == "Sony Vaio i3") { //Creando una instancia de la fabrica Concreta Dell FCSony sony = new FCSony(); textBox1.Text = sony.configuari3() + " y por su compra usted recibira tambien: " + this.textBox2.Text; }

Page 40: Aplicacion Abstract Factory

} private void Form1_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { if (c == null) // Si c no se ha creado { // Crear instancia única. c = Regalo.getInstancia(); textBox2.Text= c.establecerRegalo(this.comboBox2.Text); } } private void button2_Click(object sender, EventArgs e) { // Crear borra la instancia c, por si el cliente decide cambiar de opinión en su regalo.

c = null; this.textBox2.Text = ""; } } }

3.3 CLIENTE PHP (SE INCLUYE CSS)

<title>Parcial Practico</title>

<style type="text/css">

<!--

#title {

font-family: "Arial Black", Gadget, sans-serif;

font-size: 24px;

Page 41: Aplicacion Abstract Factory

font-style: normal;

color: #009;

text-align: center;

}

#form1 p {

text-align: center;

}

body {

background-color: #CCC;

}

#form1 p {

font-size: 12px;

}

#form1 p {

font-size: 16px;

}

#form1 p {

font-size: 18px;

}

-->

</style></head>

<body>

Page 42: Aplicacion Abstract Factory

<?php

///CODIGO DEL CLIENTE.

if (!$_POST) ///si no se ha enviado el post, entonces crear la estructura de entrada basica.

{

echo "

<p id='title'>BEST BUY LAPTOPS</p>

<form id='form1' name='form1' method='post' action=''>

<p>Paso_1<br />

Seleccione Su Marca y Modelo:

<select name='cbmodelo' id='cbmodelo'>

<option value='Dell Studio i7' selected='selected'>Dell Studio i7</option>

<option value='Hp Pavilion i7'>Hp Pavilion i7</option>

<option value='Sony Vaio i7'>Sony Vaio i7</option>

<option value='Dell Studio i5'>Dell Studio i5</option>

<option value='Hp Pavilion i5'>Hp Pavilion i5</option>

<option value='Sony Vaio i5'>Sony Vaio i5</option>

<option value='Dell Studio i3'>Dell Studio i3</option>

<option value='Hp Pavilion i3'>Hp Pavilion i3</option>

<option value='Sony Vaio i3'>Sony Vaio i3</option>

</select>

</p>

<p>&nbsp;</p>

<p>Paso_2</p>

Page 43: Aplicacion Abstract Factory

<p>Por su compra usted obtiene un regalo:

<select name='cbRegalo' id='cbRegalo'>

<option value='Mouse Bluetooh MS' selected='selected'>Mouse Bluetooh MS</option>

<option value='Canon ip5000'>Canon ip5000</option>

<option value='Book Bag Targus'>Book Bag Targus</option>

</select>

</p>

<p>*solo se permite un regalo por compra.</p>

<p>&nbsp;</p>

<p>Paso_3 </p>

<p>PROCESAR SU TRANSACCION:</p>

<p>

<input type='submit' name='btnImprimir' id='btnImprimir' value='Ver Configuracion' />

</p>

<p>&nbsp;</p>

</form>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p> ";

}

else

{

Page 44: Aplicacion Abstract Factory

//Obteniendo valores posteados.

$cbModelo = $_POST["cbmodelo"];

$cbRegalo = $_POST["cbRegalo"];

//Creando estructura HTML de la pagina nuevamente.

echo "

<p id='title'>BEST BUY LAPTOPS</p>

<form id='form1' name='form1' method='post' action=''>

<p>Paso_1<br />

Seleccione Su Marca y Modelo:

<select name='cbmodelo' id='cbmodelo'>

<option value='Dell Studio i7' selected='selected'>Dell Studio i7</option>

<option value='Hp Pavilion i7'>Hp Pavilion i7</option>

<option value='Sony Vaio i7'>Sony Vaio i7</option>

<option value='Dell Studio i5'>Dell Studio i5</option>

<option value='Hp Pavilion i5'>Hp Pavilion i5</option>

<option value='Sony Vaio i5'>Sony Vaio i5</option>

<option value='Dell Studio i3'>Dell Studio i3</option>

<option value='Hp Pavilion i3'>Hp Pavilion i3</option>

<option value='Sony Vaio i3'>Sony Vaio i3</option>

</select>

</p>

<p>&nbsp;</p>

Page 45: Aplicacion Abstract Factory

<p>Paso_2</p>

<p>Por su compra usted obtiene un regalo:

<select name='cbRegalo' id='cbRegalo'>

<option value='Mouse Bluetooh MS' selected='selected'>Mouse Bluetooh MS</option>

<option value='Canon ip5000'>Canon ip5000</option>

<option value='Book Bag Targus'>Book Bag Targus</option>

</select>

</p>

<p>*solo se permite un regalo por compra.</p>

<p>&nbsp;</p>

<p>Paso_3 </p>

<p>PROCESAR SU TRANSACCION:</p>

<p>

<input type='submit' name='btnImprimir' id='btnImprimir' value='Ver Configuracion' /> <br/>

<br/>";

//Cliente Singleton: Define el Regalo

$regalo = Regalo::getInstancia(); // Obteniendo instancia

echo '<br/><h2><center> <b>Felicidades Por su Compra usted obtuvo: '. $regalo-

>establecerRegalo($cbRegalo); //llamando al metodo que obtiene el regalo

unset($regalo); // Eliminando instancia

//Cliente Abstract Factory define que clase llamar.

Page 46: Aplicacion Abstract Factory

///ESTRUCTURAS DE DECISION PARA PEDIDOS DE LA MARCA DELL

if ($cbModelo == "Dell Studio i7")

{

//Creando una instancia de la fabrica Concreta Dell

$dell = new FCDell();

echo '<br> <br> Su configuracion es la siguiente:'. $dell->configuari7().

'<center/><h2/><b/>';

}

if ($cbModelo == "Dell Studio i5")

{

//Creando una instancia de la fabrica Concreta Dell

$dell = new FCDell();

echo '<br> <br> Su configuracion es la siguiente:'. $dell->configuari5().

'<center/><h2/><b/>';

}

if ($cbModelo == "Dell Studio i3")

{

//Creando una instancia de la fabrica Concreta Dell

$dell = new FCDell();

echo '<br> <br> Su configuracion es la siguiente:'. $dell->configuari3().

'<center/><h2/><b/>';

}

///ESTRUCTURAS DE DECISION PARA PEDIDOS DE LA MARCA HP

if ($cbModelo == "Hp Pavilion i7")

Page 47: Aplicacion Abstract Factory

{

//Creando una instancia de la fabrica Concreta Hp

$hp = new FCHP();

echo '<br> <br> Su configuracion es la siguiente:'. $hp->configuari7().

'<center/><h2/><b/>';

}

if ($cbModelo == "Hp Pavilion i5")

{

//Creando una instancia de la fabrica Concreta Hp

$hp = new FCHP();

echo '<br> <br> Su configuracion es la siguiente:'. $hp->configuari5().

'<center/><h2/><b/>';

}

if ($cbModelo == "Hp Pavilion i3")

{

//Creando una instancia de la fabrica Concreta Hp

$hp = new FCHP();

echo '<br> <br> Su configuracion es la siguiente:'. $hp->configuari3().

'<center/><h2/><b/>';

}

///ESTRUCTURAS DE DECISION PARA PEDIDOS DE LA MARCA SONY

if ($cbModelo == "Sony Vaio i7")

{

//Creando una instancia de la fabrica Concreta Sony

$sony = new FCSony();

Page 48: Aplicacion Abstract Factory

echo '<br> <br> Su configuracion es la siguiente:'. $sony->configuari7().

'<center/><h2/><b/>';

}

if ($cbModelo == "Sony Vaio i5")

{

//Creando una instancia de la fabrica Concreta Sony

$sony = new FCSony();

echo '<br> <br> Su configuracion es la siguiente:'. $sony->configuari5().

'<center/><h2/><b/>';

}

if ($cbModelo == "Sony Vaio i3")

{

//Creando una instancia de la fabrica Concreta Sony

$sony = new FCSony();

echo '<br> <br> Su configuracion es la siguiente:'. $sony->configuari3().

'<center/><h2/><b/>';

}

//Completando etiquetas html para mantener el aspecto.

echo " </p>

<p>&nbsp;</p>

</form>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p> ";

} ?>

Page 49: Aplicacion Abstract Factory

4 CAPTURA DE PANTALLA DE INTERFAZ DE USUARIO.

4.1 VISUAL BASIC

Nota: se muestra también el explorador de la solución como comprobante de existencia de las clases.

Page 50: Aplicacion Abstract Factory

4.2 VISUAL C SHARP

Nota: se muestra tambien el explorador de la solucion como comprobante de existencia de las clases.

Page 51: Aplicacion Abstract Factory

4.3 PHP

Page 52: Aplicacion Abstract Factory

5 CAPTURA DE PANTALLA DE PROGRAMA

EJECUTANDOSE

5.1 VISUAL BASIC

Page 53: Aplicacion Abstract Factory

5.2 VISUAL C SHARP

Page 54: Aplicacion Abstract Factory

5.3 PHP