Dc2b5374b8c24a20577346b9b1e4891f

How can i refactor theese codes?

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 !

D41d8cd98f00b204e9800998ecf8427e

anon

June 4, 2010, June 04, 2010 01:06, permalink

No rating. Login to rate!
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();
        }
    }



}
94f928c5cde29a190e2062fc7bb7fbdb

Kathy Wu

June 4, 2010, June 04, 2010 02:40, permalink

1 rating. Login to rate!
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; }
    }

Your refactoring





Format Copy from initial code

or Cancel