C sharp - Orientacion con este codigo

 
Vista:

Orientacion con este codigo

Publicado por jesus (1 intervención) el 23/11/2008 18:39:09
Hola... Bueno mi problema es este eh hecho este codigo pero el profesor que me lo pidio quiere que mueva esta parte:

public void Capturandodatos()
{
Console.Write(" INTRODUZCA SU VALOR: ");
V1 = Single.Parse(Console.ReadLine());

}

hacia la clase principal osea que se ejecute aqui:

class RESULTADOS
{
public static void Main()
{
VALORES Referencia;
CUADRADO X = new CUADRADO();//creamos un objeto

Referencia = X;//aqui la referencia hace la llamada para obtener el resultado
Console.WriteLine(" EL RESULTADO DEL CUADRADO ES: " + Referencia.OPERACIONES());

CUBO Y = new CUBO();
Referencia = Y;
Console.WriteLine(" EL RESULTADO DEL CUBO ES: " + Referencia.OPERACIONES());

FACTORIAL Z = new FACTORIAL();
Referencia = Z;
Console.WriteLine(" EL RESULTADO DEL FACTORIAL ES: " + Referencia.OPERACIONES());
Console.ReadLine();
}
}

osea en la clase principal y pues la verdad no eh podido :S por favor me podrian dar una orientacion de como podria hacerlo
aqui pongo lo que es el codigo completo

using System;
class VALORES
{
protected double V1;// primer valor
protected double C;// cuadrado
protected double CU;//cubo
protected double T;//total

public void Capturandodatos()
{
Console.Write(" INTRODUZCA SU VALOR: ");
V1 = Single.Parse(Console.ReadLine());

}
public virtual double OPERACIONES()
{
return (0);
}
}
class CUADRADO : VALORES
{
public override double OPERACIONES()
{
Capturandodatos();
C = (V1 * V1); //se calcula el cuadrado de un numero dado
T = (C);// le asigno el valor obtenido a otra variable
return (T);
}
}

class CUBO : VALORES
{
public override double OPERACIONES()
{
Capturandodatos();
CU = (V1 * V1 * V1);
T = (CU);
return (T);
}
}

class FACTORIAL : VALORES
{
public override double OPERACIONES()
{
Capturandodatos();
int i, fact = 1;

for (i = 1; i <= V1; i++)
{
fact = fact * i;
}

T = (fact);
return (T);
}
}

class RESULTADOS
{
public static void Main()
{
VALORES Referencia;
CUADRADO X = new CUADRADO();

Referencia = X;
Console.WriteLine(" EL RESULTADO DEL CUADRADO ES: " + Referencia.OPERACIONES());

CUBO Y = new CUBO();
Referencia = Y;
Console.WriteLine(" EL RESULTADO DEL CUBO ES: " + Referencia.OPERACIONES());

FACTORIAL Z = new FACTORIAL();
Referencia = Z;
Console.WriteLine(" EL RESULTADO DEL FACTORIAL ES: " + Referencia.OPERACIONES());
Console.ReadLine();
}
}

serie de mucha ayuda si me pudiesen orientar y en todo caso como quedaria el codigo gracias de antemano
saludos
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder