View Single Post
Newbie Member
27Nov2008,19:35  
honeyboy_20's Avatar
Thanks , u say that u want to adapt to return float instead of int so u will make adapter to Itarget but it still return integer so we not make any changes.

PHP Code:
using System;
using System.Collections.Generic;
using System.Text;

namespace 
DesignPattern
{
    public abstract class 
ITarget
    
{
        abstract public 
int Add(int aint b);
    }

    public abstract class 
INewTarget
    
{
        abstract public 
float Add(float afloat b);
    }

    
/// <summary>
    /// Old Implementation of calculator library had ITarget and now its INewTarget
    /// </summary>
    
class Calculator INewTarget
    
{
        public 
override float Add(float afloat b)
        {
            return 
b;
        }
    }

    public class 
CalcAdapter ITarget
    
{
        private 
Calculator calc;

        public 
CalcAdapter()
        {
            
calc = new Calculator();
        }

        public 
override int Add(int aint b)
        {
            return (int)
calc.Add((float)a, (float)b);
        }
    }