diseño de sistemas
DESCRIPTION
Metrica Diseño de SistemasTRANSCRIPT
-
PROGRAMACIN ORIENTADA A OBJETOS
Diseo e implementacin de Clases
22 DE JUNIO DE 2015 PROFESOR ZEN OMAEL ROBLES MONTERO
UPVM
Jara Cruz Marlen
Jimnez Zamora Juan Mauricio
Moreno Snchez Mariana Alejandra
-
Objetivo de las clases:
La programacin orientada a objetos se rige por ciertos principios uno de esos principio son las clases que comprenden
el diseo e implementacin esto es especificar como sern los objetos de las clases y las variables alojadas en este esto se hace
mediante una declaracin precedido por una palabra de clave de clase para ser utilizadas.
Diagramas de clases de Almacn
En el diagrama esta representado por un clase principal llamada almacn el cual consta de 4 elementos clientes,
proveedores, productos, pedidos y a su vez cada elemento tienen una sub clase en la que encuentran los elementos.
Codigo
package almacen;
-
import java.util.*;
import java.io.*;
public class Almacen {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner e=new Scanner(System.in);
int opc=0;
System.out.println("Menu\n1.-Clientes\n2.-Proveedores\n3.-Productos\n4.-Pedidos\n");
opc=e.nextInt();
switch(opc)
{
case 1:
Clientes();
Almacen.main(null);
break;
case 2:
Proveedores();
Almacen.main(null);
break;
case 3:
Productos();
Almacen.main(null);
break;
case 4:
Pedidos();
Almacen.main(null);
break;
}
}
public static void Clientes()
{
Scanner t=new Scanner(System.in);
Clientes c=new Clientes();
System.out.println("Ingresa Nombre");
c.nom=t.next();
System.out.println("Ingresa telefono");
c.tel=t.next();
System.out.println("Ingresa direccion");
c.dir=t.next();
System.out.println("Ingresa Razon Social");
c.raz=t.next();
}
public static void Proveedores()
{
Scanner t=new Scanner(System.in);
Proveedores pr=new Proveedores();
System.out.println("Ingresa nombre del proveedor");
pr.nom=t.next();
-
System.out.println("Ingresa Direccion");
pr.dir=t.next();
System.out.println("Ingresa razon social");
pr.raz=t.next();
System.out.println("Ingresa giro");
pr.gir=t.next();
}
public static void Productos ()
{
Scanner t=new Scanner (System.in);
Productos p=new Productos ();
System.out.println("Ingresa el nombre del producto");
p.nom=t.next();
System.out.println("Ingresa la cantidad");
p.cant=t.next();
System.out.println("Ingresa Marca");
p.mod=t.next();
System.out.println("Ingresa modelo");
p.mod=t.next();
}
public static void Pedidos()
{
Scanner t=new Scanner (System.in);
Pedidos ped=new Pedidos();
System.out.println("Ingresa numero de pedido");
ped.num=t.next();
System.out.println("Ingresa nombre del cliente");
ped.prov=t.next();
System.out.println("Ingresa productos");
ped.prod=t.next();
System.out.println("Ingresa Cantidad");
ped.cant=t.nextInt();
}
}
-
Conclusin.
La implementacin de clases son de mucha utilidad ya que agrupa los mtodos y podemos seccionar para despus ser utilizado en el
programa principal el cual se representa de manera ordenada y el diseo es representado del tan manera para facilitar su entendimiento
gracias a los diagramas de clases lo cual hace que haya un procedimiento y orden en el programa.
Bibliografa.
DEITEL, HARVEY M. Y DEITEL, PAUL J. CUARTA EDICION COMO DIBUJAR EN JAVA PEARSON EDUCACION, MEXICO 2004.
-
Diagrama de Clase de Operaciones
El diagrama es representado por la principal clase que es Operaciones, donde estarn las dems clases que son
Suma
Resta
Multiplicacin
Divisin
Operaciones
*Suma-*Resta-*Multiplicacin-*Divisin
Suma
*numero 1 INT
*numero 2 INT
*resultado INT
*numero real INT
*numero imag INT
*numero real INT
*numero imag INT
*resultado INT
Resta
*numero 1 INT
*numero 2 INT
*resultado INT
*numero real INT
*numero imag INT
*numero real INT
*numero imag INT
*resultado INT
Multiplicacin
*numero 1 INT
*numero 2 INT
*resultado INT
*numero real INT
*numero imag INT
*numero real INT
*numero imag INT
*resultado INT
Divisin
*numero 1 Doubl
*numero 2 Doubl
*resultado Doubl
*numero real Doubl
*numero imag Doubl
*numero real Doubl
*numero imag Doubl
*resultado Doubl
Atributos Atributos Atributos Atributos
-
Cdigo package operaciones;
import java.util.*;
import java.io.*;
import java.util.Scanner;
public class Operaciones {
public static void main(String[] args) {
Scanner teclado= new Scanner (System.in);
int a=0;
System.out.println("1-Suma\n2-Resta \n3-Multiplicacion \n4-Division");
a=teclado.nextInt();
switch (a){
case 1: Suma(); Operaciones.main(null); break;
case 2: Resta(); Operaciones.main(null); break;
case 3: Multiplicacion(); Operaciones.main(null); break;
case 4: Division();Operaciones.main(null); break;
}
}
public static void Suma()
{
Scanner t=new Scanner(System.in);
Suma c=new Suma();
System.out.println("Ingrese 1er valor");
c.n1=t.nextInt();
System.out.println("Ingresa 2do valor");
c.n2=t.nextInt();
c.r1=c.n1+c.n2;
System.out.println("El resultado entero es"+c.r1);
System.out.println("El resultado racional es:"+c.r1+"/"+"1");
System.out.println("Dame numero real");
c.a=t.nextInt();
System.out.println("Dame numero imaginario");
c.b=t.nextInt();
System.out.println("Dame numero real");
c.c=t.nextInt();
System.out.println("Dame numero imaginario");
c.d=t.nextInt();
c.r3=c.a+c.c;
c.r4=c.b+c.d;
System.out.println("El resultado complejo es:"+c.r3+ "+" +c.r4+"i" );
}
public static void Resta()
{
Scanner t=new Scanner(System.in);
Resta r=new Resta();
System.out.println("Ingrese 1er valor");
r.n1=t.nextInt();
System.out.println("Ingresa 2do valor");
r.n2=t.nextInt();
r.r1=r.n1-r.n2;
System.out.println("El resultado entero es"+r.r1);
System.out.println("El resultado racional es:"+r.r1+"/"+"1");
System.out.println("Dame numero real");
r.a=t.nextInt();
System.out.println("Dame numero imaginario");
r.b=t.nextInt();
System.out.println("Dame numero real");
r.c=t.nextInt();
System.out.println("Dame numero imaginario");
r.d=t.nextInt();
r.r3=r.a-r.c;
r.r4=r.b-r.d;
System.out.println("El resultado complejo es:" +r.r3 + "-"+ r.r4+"i" );
}
public static void Multiplicacion()
{
Scanner t=new Scanner(System.in);
Mutiplicacion m=new Mutiplicacion();
System.out.println("Ingrese 1er valor");
m.n1=t.nextInt();
System.out.println("Ingresa 2do valor");
m.n2=t.nextInt();
m.r1=m.n1*m.n2;
System.out.println("El resultado entero es"+m.r1);
System.out.println("El resultado racional es:"+m.r1+"/"+"1");
System.out.println("Dame numero real");
-
m.a=t.nextInt();
System.out.println("Dame numero imaginario");
m.b=t.nextInt();
System.out.println("Dame numero real");
m.c=t.nextInt();
System.out.println("Dame numero imaginario");
m.d=t.nextInt();
m.r3=m.a*m.c;
m.r4=m.a*m.d;
m.r5=m.b*m.c;
m.r6=m.b*m.d;
m.k=m.r4+m.r5;
m.r6=(-1)*m.r6;
m.j=m.r6+m.r3;
System.out.println("El resultado complejo es:"+m.r3);
}
public static void Division()
{
Scanner t=new Scanner(System.in);
Division d=new Division();
System.out.println("Ingrese 1er valor");
d.n1=t.nextInt();
System.out.println("Ingresa 2do valor");
d.n2=t.nextInt();
d.r1=d.n1/d.n2;
System.out.println("El resultado entero es"+d.r1);
System.out.println("El resultado racional es:"+d.r1+"/"+"1");
System.out.println("Dame numero real");
d.a=t.nextInt();
System.out.println("Dame numero imaginario");
d.b=t.nextInt();
System.out.println("Dame numero real");
d.c=t.nextInt();
System.out.println("Dame numero imaginario");
d.d=t.nextInt();
System.out.println("El resultado complejo es:"+d.r3);
}
Conclusin:
Marlen: El hecho de usar clases en nuestro cdigo tiene ventajas,
ya que nos sirve para definir mejor nuestro programa teniendo
un mejor entendimiento para la ejecucin del mismo, al mismo
tiempo optimiza cdigo
-
1 GESTION DE PARTIDO DE FUTBOL
package gpartidofut;
import java.util.Scanner;
import java.io.*;
public class GPartidofut {
public static void main(String[] args) {
Scanner t=new Scanner(System.in);
int opc=0;
System.out.println("Menu:\n1.-JUGADORES:\n2.-EQUIPOS\n3.-ARBITROS\n4.- CALENDARIO DE PARTIDOS\n");
opc=t.nextInt();
switch(opc){
case 1:
Jugadores();
GPartidofut.main(null);
break;
case 2:
equipo();
GPartidofut.main(null);
break;
case 3:
arbitros ();
GPartidofut.main(null);
break;
case 4:
calendario();
GPartidofut.main(null);
break;
-
}
}
public static void Jugadores(){
Jugadores j=new Jugadores ();
Scanner t=new Scanner(System.in);
System.out.println("Ingresa tu nombre:");
j.nom= t.next();
System.out.println("Ingresa tu edad:");
j.edad=t.next();
System.out.println("Ingresa tu Estatura:");
j.Estatura=t.nextDouble();
System.out.println("Ingresa tu Peso:");
j.peso=t.nextInt();
System.out.println("Ingresa tu Posicion:");
j.posicion=t.next();
System.out.println("Ingresa tu numero de jugador:");
j.nupl=t.nextInt();
}
public static void equipo(){
equipo e=new equipo();
Scanner t=new Scanner(System.in);
System.out.println("Ingresa nombre equipo local:");
e.eL= t.next();
System.out.println("Ingresa la Procedencia:");
e.Proce=t.next();
System.out.println("Ingresa nombre de entrenador:");
e.Ent=t.next();
System.out.println("Ingresa nombre equipo visitante:");
e.eV=t.next();
System.out.println("Ingresa la Procedencia:");
e.Proce=t.next();
-
System.out.println("Ingresa nombre de entrenador:");
e.Ent=t.next();
}
public static void arbitros (){
arbitros a=new arbitros ();
Scanner t=new Scanner(System.in);
System.out.println("Ingresa tu nombre:");
a.nom= t.next();
System.out.println("Ingresa tu edad:");
a.edad=t.next();
System.out.println("Ingresa tu Estatura:");
a.Estatura=t.nextDouble();
System.out.println("Ingresa tu Peso:");
a.peso=t.nextInt();
System.out.println("Ingresa tu Experiencia:");
a.aex=t.next();
}
public static void calendario (){
calendario c=new calendario ();
Scanner t=new Scanner(System.in);
System.out.println("Ingresa dia:");
c.dia= t.nextInt();
System.out.println("Ingresa hora:");
c.hora=t.nextInt();
System.out.println("Ingresa mes :");
c.mes=t.next();
System.out.println("Ingresa Jornada:");
c.jor=t.next();
}
}
-
DIAGRAMA DE CLASES
tiene
Jugadores ();
Nombre: String Edad:String Estatura: Double Peso: int Posicion:String NumJugador:String
Equipo();
Nombre Equipo Local: String Nombre Equipo Visitante:String Procedencia: String Nombre de entrenador: String
Arbitro();
Nombre: String Edad:String Estatura: Double Peso: int Experiencia:String
Calendario ();
dia: String mes:String hra: int Jornada:String
OBJETO GPartidofut
Jugadores
Equipo
Arbitro
Calendario de partidos