示例#1
0
        static void Main(string[] args)
        {
            NewClass NewObject = new NewClass();

            NewObject.setName("Cary Grant");
            LegacyClass adapter = new NewToLegacyAdapter(NewObject);

            Console.WriteLine("Customer’s first name: " + adapter.getFirstName());
            Console.WriteLine("Customer’s last name: " + adapter.getLastName());

            Console.ReadKey();
        }
示例#2
0
 public NewToLegacyAdapter(NewClass NewObject)
 {
     setFirstName(NewObject.getName().Split(' ')[0]);
     setLastName(NewObject.getName().Split(' ')[1]);
 }