miércoles, 28 de octubre de 2009

pRuEbA!!!!

/**
*
* @author Johana Ruales
*/
public class Matriz {
public int numeroFilas;
public int numeroColumnas;
public int [][]matriz;

public Matriz(){//crea una matriz sin dimensiones

}

//constructor con parametros
//nF es el numero de filas de la matriz
//nC es el numero de columnas de la matriz
public Matriz(int nF, int nC){
numeroFilas=nF;
numeroColumnas=nC;
matriz=new int[numeroFilas][numeroColumnas];
for(int i=0; i for(int j=0; j matriz [i][j]=0;
}

//Transpuesta de la matriz
//el numero de filas se cambia al numero de columnas
public Matriz Transpuesta(){
Matriz resultado;
resultado=new Matriz(this.numeroColumnas,this.numeroFilas);
for(int i=0; i for(int j=0; j resultado.matriz[j][i]=this.matriz[i][j];
return resultado;
}

//multiplicacion de matrices
//el numero de filas de la primera tiene que ser igual al numero de columnas
//de la otra matriz
public Matriz Multiplicacion(Matriz b){
Matriz resultado;
if(b.numeroFilas==this.numeroColumnas){
resultado=new Matriz(this.numeroFilas, b.numeroColumnas);
for(int i=0; i for(int j=0; j for(int k=0; k resultado.matriz[i][j]+=this.matriz[i][k]*b.matriz[k][j];
}
}
return resultado;
}
else
System.out.println("ERROR EN DIMENSIONES DE LAS MATRICES");
resultado=null;
return resultado;
}

//metodo para imprimir las matrices
//devulve el objeto matriz como texto
public String toString(){
String aux="\n[\n";
for(int i=0; i for(int j=0; j aux+=matriz[i][j]+" ";
}
aux+="\n";
}
aux+="]";
return aux;
}

}

PRUEBA MATRIZ

/**
*
* @author Johana Ruales
*/
public class PruebaMatriz {
public static void main(String args[]){
Matriz a=new Matriz(1,5);
a.matriz[0][0]=1; a.matriz[0][1]=-1; a.matriz[0][2]=0; a.matriz[0][3]=1; a.matriz[0][4]=1;
//System.out.println("LA MATRIZ A ES: "+a.toString());

Matriz b=new Matriz (5,3);
b.matriz[0][0]=6; b.matriz[0][1]=-2; b.matriz[0][2]=5;
b.matriz[1][0]=4; b.matriz[1][1]=2; b.matriz[1][2]=-1;
b.matriz[2][0]=0; b.matriz[2][1]=1; b.matriz[2][2]=1;
b.matriz[3][0]=-2; b.matriz[3][1]=-2; b.matriz[3][2]=0;
b.matriz[4][0]=1; b.matriz[4][1]=0; b.matriz[4][2]=-1;
//System.out.println("LA MATRIZ B ES: "+b.toString());

Matriz c=new Matriz (2,3);
c.matriz[0][0]=2; c.matriz[0][1]=2; c.matriz[0][2]=1;
c.matriz[1][0]=3; c.matriz[1][1]=-1; c.matriz[1][2]=0;
//System.out.println("LA MATRIZ C ES: "+c.toString());

Matriz e=new Matriz(3,3);
e.matriz[0][0]=-1; e.matriz[0][1]=0; e.matriz[0][2]=-1;
e.matriz[1][0]=1; e.matriz[1][1]=0; e.matriz[1][2]=1;
e.matriz[2][0]=-1; e.matriz[2][1]=1; e.matriz[2][2]=-1;
//System.out.println("LA MATRIZ E ES: "+e.toString());


System.out.println("EL RESULTADO UNO ES: ");
Matriz u;
u=c.Multiplicacion(e);
System.out.println("EL RESULTADO DE MULTIPLICAR CE ES: "+u.toString());

Matriz o;
o=b.Transpuesta();
System.out.println("\nLA MATRIZ TRANSPUESTA DE B ES: "+o.toString());

Matriz ñ;
ñ=u.Multiplicacion(o);
System.out.println("\nEL RESULTADO CEBt ES: "+ñ.toString());

System.out.println("\n\nEL RESULTADO DOS ES: ");
Matriz d;
d=a.Multiplicacion(b);
System.out.println("EL RESULTADO DE MULTIPLICAR AB: "+d.toString());

Matriz p;
p=d.Multiplicacion(e);
System.out.println("\nEL RESULTADO DE MULTIPLICAR ABE ES: "+p.toString());

System.out.println("\n\nEL RESULTADO TRES ES: ");
Matriz w;
w=b.Transpuesta();
System.out.println("LA MATRIZ TRANSPUESTA DE B ES: "+w.toString());

Matriz x;
x=a.Transpuesta();
System.out.println("\nLA MATRIZ TRANSPUESTA DE A ES: "+x.toString());

Matriz t;
t=e.Multiplicacion(w);
System.out.println("\nLA MULTIPLICACION DE EBt ES: "+t.toString());

Matriz y;
y=t.Multiplicacion(x);
System.out.println("\nEL RESULTADO DE MULTIPLICAR EBtAt ES: "+y.toString());
}
}

RESULTADOS

EL RESULTADO UNO ES:
EL RESULTADO DE MULTIPLICAR CE ES:
[
-1 1 -1
-4 0 -4
]

LA MATRIZ TRANSPUESTA DE B ES:
[
6 4 0 -2 1
-2 2 1 -2 0
5 -1 1 0 -1
]

EL RESULTADO CEBt ES:
[
-13 -1 0 0 0
-44 -12 -4 8 0
]


EL RESULTADO DOS ES:
EL RESULTADO DE MULTIPLICAR AB:
[
1 -6 5
]

EL RESULTADO DE MULTIPLICAR ABE ES:
[
-12 5 -12
]


EL RESULTADO TRES ES:
LA MATRIZ TRANSPUESTA DE B ES:
[
6 4 0 -2 1
-2 2 1 -2 0
5 -1 1 0 -1
]

LA MATRIZ TRANSPUESTA DE A ES:
[
1
-1
0
1
1
]

LA MULTIPLICACION DE EBt ES:
[
-11 -3 -1 2 0
11 3 1 -2 0
-13 -1 0 0 0
]

EL RESULTADO DE MULTIPLICAR EBtAt ES:
[
-6
6
-12
]

domingo, 18 de octubre de 2009

MULTIPLICACION DE MATRICES

MULTIPLICACION

/**
*
* @author JoHaNa RuAlEs
*/
public class Matriz {
public int numeroFilas;
public int numeroColumnas;
public int [][]matriz;

public Matriz(){//crear una matriz sin dimensiones
}

public Matriz(int nF, int nC){
numeroFilas=nF;
numeroColumnas=nC;
matriz=new int [numeroFilas][numeroColumnas];

for(int i=0; i < numeroFilas; i++)
for(int j=0; j < numeroColumnas; j++)
matriz[i][j]=0;
}

//MULTIPLICACION

public Matriz multiplicacion(Matriz b){
Matriz resultado;
int suma=0;
int resta;
if((this.numeroFilas == b.numeroColumnas) {
resultado=new Matriz(this.numeroFilas,b.numeroColumnas);
for(int i=0; i < this.numeroFilas; i++){
for(int j=0; j < b.numeroColumnas; j++){
for(int k=0; k < this.numeroColumnas; k++)
resultado.matriz[i][j]=(this.matriz[i][k]*b.matriz[k][j]);
}
}
return resultado;
}
else
System.out.println("ERROR EN DIMENSIONES DE LAS MATRICES");
resultado=null;
return resultado;
}

public String toString(){
String aux="\n[\n";
for(int i=0; i < numeroFilas; i++){
for(int j=0; j < numeroColumnas; j++){
aux+=matriz[i][j]+" ";
}
aux+="\n";
}
aux+="]";
return aux;
}
}

USO MATRIZ

/**
*
* @author User
*/
public class PruebaMatriz {
public static void main(String args[]){
Matriz a = new Matriz(3,2);
a.matriz[0][0]=1; a.matriz[0][1]=2;
a.matriz[1][0]=3; a.matriz[1][1]=4;
a.matriz[2][0]=5; a.matriz[2][1]=6;
System.out.println(a.toString());

Matriz b = new Matriz(2,3);
b.matriz[0][0]=7; b.matriz[0][1]=8; b.matriz[0][2]=9;
b.matriz[1][0]=10; b.matriz[1][1]=11; b.matriz[1][2]=12;
System.out.println(b.toString());

Matriz c;
c=a.multiplicacion(b);
System.out.println(c.toString());
}

}

martes, 13 de octubre de 2009

programa figuras

CUADRADO

/**
*
* @author User
*/
public class Cuadrado {
private double valorLado;
private double valorArea;

public Cuadrado(){
SetCuadrado(0,0);
}

public Cuadrado(double l, double a){
SetCuadrado(l,a);
}

public void SetCuadrado(double l, double a){
valorLado = l;
valorArea = a;
}

public double getValorLado(){
return valorLado;
}

public double getValorArea(){
return valorArea;
}

//public String toString(){
// return."VALOR DE LADO ES: "+valorLado+ "VALOR DE AREA ES: "+valorArea+";" +
//}

public static void main(String args[]){
Cuadrado c1 = new Cuadrado(3,9);
//System.out.println(c1.toString);
System.out.println("VALOR DEL LADO ES: "+c1.getValorLado());
System.out.println("VALOR DEL AREA ES: "+c1.getValorArea());
}

}

TRIANGULO

/**
*
* @author JoHaNa rUaLeS
*/
public class Triangulo extends Cuadrado{
private double altura;

public Cuadrado(){
super(0,0);
setAltura(0);
}

public Triangulo(double l, double a, double h){
super(l,a);
setAltura(h);
}

public double setAltura(double h){
altura = h;
}

public double getAltura(){
return altura;
}

public static void main(String args[]){
Triangulo t1 = new Triangulo(3,3,2);
System.out.println("EL LADO DEL TRIANGULO ES: "+t1.getValorLado());
System.out.println("LA ALTURA DEL TRIANGULO ES: "+t1.getAltura());
}


}

domingo, 11 de octubre de 2009

UNIVERSIDAD

UNIVERSIDAD

/**
*
* @author JoHaNa RuAlEs
*/
public class Universidad {
public String carrera;
public String nombre;
public int curso;

public Universidad(){
}

public Universidad(String car, String nom, int cur){
carrera = car;
nombre = nom;
curso = cur;
}
}

USO UNIVERSIDAD

/**
*
* @author JohAnA RuAlEs
*/
public class UsoUniversidad {
public static void main(String args[]){
Universidad u1 = new Universidad();
u1.carrera = "DISENO DE INTERIORES";
u1.nombre = "Milena Villa";
u1.curso = "3ro";

System.out.println("CARRERA: " +u1.carrera+ "\nNOMRE: " +u1.nombre+ "\nCURSO: " +u1.curso);

Universidad u2 = new Universidad();
u2.carrera = "INGENIERIA EN PETROLEOS";
u2.nombre = "Paola Aguirre";
u2.curso = "5to";

System.out.println("CARRERA: " +u2.carrera+ "\nNOMBRE: " +u2.nombre+ "\nCURSO: " +u2.curso);

Universidad u3 = new Universidad();
u3.carrera = "AUDITORIA Y FINANZAS";
u3.nombre = "Jonathan Vaca";
u3.curso = "1ro";

System.out.println("CARRERA: " +u3.carrera+ "\nNOMBRE: " +u3.nombre+ "\nCURSO: " +u3.curso);
}
}

CARRO

CARRO

/**
*
* @author JoHaNa RuAlEs
*/
public class Carro {
private String Placa;
public String marca;
public String modelo;

public Carro(){
}

public Carro(String mar, String mod){
marca = mar;
modelo = mod;
}

public void devolverPlaca(String plac){
Placa = plac;
}
}

USO CARRO
/**
*
* @author JohAnA RuAlEs
*/
public class UsoCarro {
public static void main(String args[]){
Carro c1 = new Carro();
c1.marca = "KIA";
c1.modelo = "cerato";
c1.asignarPlaca = "PTN474";

System.out.println("MARCA: " +c1.marca+ "\nMODELO: " +c1.modelo);

Carro c2 = new Carro();
c2.marca = "HYUNDAY";
c2.modelo = "tucson";
c2.asignarPlaca = "PKB395";

System.out.println("MARCA: " +c2.marca+ "\nMODELO: " +c2.modelo);

Carro c3 = new Carro();
c3.marca = "CHEVROLET";
c3.modelo = "corsa";
c3.asignarPlaca = "PJE987";

System.out.println("MARCA: " +c3.marca+ "\nMODELO: " +c3.modelo);


}
}

domingo, 4 de octubre de 2009

PrOgRaMaCiOn oRiEnTaDa A oBjEtOs

Es un paradigma de programación (un enfoque particular para la construcción del software) que usa objetos y sus interaciones para diseñar aplicaciones y programas de computadoras.

Los objetos son unidades que en el tiempo de ejecución realizan varias tareas de un programa, estos interactuan los unos con los otros con la capacidad de recibir mensajes, procesar los datos y enviar mensajes a otros objetos.
Son agrupados en conjuntos con las siguientes propiedades:
* Identidad: es la propiedad que diferencia un objeto del otro, en
programación compara si dos objetos son iguales(determinado por la dirección
de memoria)

* Comportamiento: es la propiedad relacionada con las funciones del objeto la
cual delimita sus tareas a realizar

* Estado: es el conjunto de los valores de los atributos en un instante de
tiempo dado

BIBLIOGRAFIA:
http://es.wikipedia.org/wiki/Programaci%C3%B3n_orientada_a_objetos