product.cs
来自「23中设计模式例子,PDF格式」· CS 代码 · 共 32 行
CS
32 行
using System;
namespace BasicBridge
{
/// <summary>
/// Summary description for Product.
/// </summary>
public class Product : IComparable {
private string quantity;
private string name;
//-----
public Product(string line) {
int i = line.IndexOf ("--");
name =line.Substring (0, i).Trim ();
quantity = line.Substring (i+2).Trim ();
}
//-----
public string getQuantity() {
return quantity;
}
//-----
public string getName() {
return name;
}
//-----
public int CompareTo(object p) {
Product prod =(Product) p;
return name.CompareTo (prod.getName ());
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?