Sample1_General.cs
Upload User: jasonxu888
Upload Date: 2007-03-28
Package Size: 4316k
Code Size: 1k
Category:

.net

Development Platform:

C#

  1. using System;
  2. namespace Sample1_General
  3. {
  4. public interface ICustomerManager
  5. {
  6. Customer getCustomer(int id);
  7. ValidationResult validate(Customer cust);
  8. }
  9. [Serializable] 
  10. public class ValidationResult 
  11. {
  12. public ValidationResult (bool ok, String msg) 
  13. {
  14. Console.WriteLine("ValidationResult.ctor: Object created");
  15. this.Ok = ok;
  16. this.ValidationMessage = msg;
  17. }
  18. public bool Ok;
  19. public String ValidationMessage;
  20. }
  21. [Serializable]
  22. public class Customer 
  23. {
  24. public String FirstName;
  25. public String LastName;
  26. public DateTime DateOfBirth;
  27. public Customer() 
  28. {
  29. Console.WriteLine("Customer.ctor: Object created");
  30. }
  31. public int getAge() 
  32. {
  33. Console.WriteLine("Customer.getAge(): called for Customer " + FirstName + " born on " + DateOfBirth.ToShortDateString());
  34. TimeSpan tmp = DateTime.Today.Subtract(DateOfBirth);
  35. return tmp.Days / 365; // rough estimation
  36. }
  37. }
  38. }