using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace interfaceClass
{
class Program
{
static void Main(string[] args)
{
Alan s = new Alan();
s.kenar = 56;
double sonuc = ((IAlan)s).AlanHesap();
Console.WriteLine(sonuc.ToString());
Console.ReadKey();
}
}
interface Ikenar
{
double kenar { get; set; }
}
interface Iyukseklik
{
double yukseklik {get; set;}
}
interface IAlan
{
double AlanHesap();
}
interface IHacim
{
double Hacim();
}
class Alan : Ikenar, IAlan
{
public double kenar
{
get;
set;
}
double IAlan.AlanHesap()
{
return kenar * kenar;
}
}
class Hacim : Alan, Iyukseklik
{
public double yukseklik
{
get;
set;
}
public double HacimBul()
{
return ((IAlan)this).AlanHesap()*yukseklik;
}
}
}
Refactorings
No refactoring yet !
anon
June 4, 2010, June 04, 2010 01:06, permalink
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace interfaceClass
{
class Square {
public double v{ get;set;}
public double square() { return v*v; }
}
class Program
{
static void Main(string[] args)
{
Square = new Square ();
s.v= 56;
double c = s.square()
Console.WriteLine(c.ToString());
Console.ReadKey();
}
}
}
Kathy Wu
June 4, 2010, June 04, 2010 02:40, permalink
interface IShape
{
double GetArea();
}
interface IContainer
{
double GetVolume();
}
public class Square : IShape
{
public double width { get; set; }
public double GetArea() { return width * width;}
}
public class SquarePrism : Square, IContainer
{
public double height { get; set; }
public double GetVolume() { return GetArea() * height; }
}
How can i refactor theese codes?