22. public abstract class Animal
{
public abstract string Bark();
}
public class Cat : Animal
{
public override string Bark()
{ return “ ”}
}
public class Dog : Animal
{
public override string Bark()
{ return “ ”}
}
*All rights reserved by 5173
11
23. public abstract class Animal public interface IBarkable
{ {
public abstract string Bark(); string Bark();
} }
public class Cat : Animal public class Cat : IBarkable
{ {
public override string Bark() public string Bark()
{ return “ ”} { return “ ”}
} }
public class Dog : Animal public class Dog : IBarkable
{ {
public override string Bark() public string Bark()
{ return “ ”} { return “ ”}
} }
*All rights reserved by 5173
11
31. •
•
•
•
public class Cargo
{
public string Id { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
}
*All rights reserved by 5173
13
32. •
•
•
•
public class Cargo public class PaymentService
{ {
public string Id { get; set; } public void Pay(Cargo cargo)
public string Name { get; set; } {
public decimal Price { get; set; } //
} }
}
*All rights reserved by 5173
13
36. public class Cargo
{
public string Id { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
public enum CargoType { get; set; } //
public double Discount { get; set; } //
}
*All rights reserved by 5173
16
37. public class Cargo
{
public string Id { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
public enum CargoType { get; set; } //
public double Discount { get; set; } //
}
public class PaymentService
{
public void Pay(Cargo cargo)
{
// CargoType Discount
}
}
*All rights reserved by 5173
16
43. …
Cargo
public interface IChargable
{
void Pay();
}
*All rights reserved by 5173
18
44. …
Cargo
public interface IChargable
{
void Pay();
}
public abstract class Cargo : IChargable
{
public string Id { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
public enum CargoType { get; set; }
public double Discount { get; set; }
public abstract void Pay();
}
*All rights reserved by 5173
18
47. …
Cargo
public class Book : Cargo
{
public override void Pay() { // 8 }
}
*All rights reserved by 5173
19
48. …
Cargo
public class Book : Cargo
{
public override void Pay() { // 8 }
}
public class ElecEquip : Cargo
{
public override void Pay() { // 2000 300 }
}
*All rights reserved by 5173
19
49. …
Cargo
public class Book : Cargo
{
public override void Pay() { // 8 }
}
public class ElecEquip : Cargo
{
public override void Pay() { // 2000 300 }
}
*All rights reserved by 5173
19