Sample1_General.cs
上传用户:jasonxu888
上传日期:2007-03-28
资源大小:4316k
文件大小:1k
- using System;
- namespace Sample1_General
- {
- public interface ICustomerManager
- {
- Customer getCustomer(int id);
- ValidationResult validate(Customer cust);
- }
- [Serializable]
- public class ValidationResult
- {
- public ValidationResult (bool ok, String msg)
- {
- Console.WriteLine("ValidationResult.ctor: Object created");
- this.Ok = ok;
- this.ValidationMessage = msg;
- }
- public bool Ok;
- public String ValidationMessage;
- }
- [Serializable]
- public class Customer
- {
- public String FirstName;
- public String LastName;
- public DateTime DateOfBirth;
- public Customer()
- {
- Console.WriteLine("Customer.ctor: Object created");
- }
- public int getAge()
- {
- Console.WriteLine("Customer.getAge(): called for Customer " + FirstName + " born on " + DateOfBirth.ToShortDateString());
- TimeSpan tmp = DateTime.Today.Subtract(DateOfBirth);
- return tmp.Days / 365; // rough estimation
- }
- }
- }