Esempio n. 1
0
        public List <InstrumentsSpec> Seach(InstrumentsSpec m_instrumensSpec)
        {
            List <InstrumentsSpec> myList = new List <InstrumentsSpec>();

            foreach (var item in Instruments_List)
            {
                if (!Match(item.InstrumensSpec, m_instrumensSpec))
                {
                    continue;
                }
                //首先进行类型的转换,然后判断是不是可以进行匹配

                if (m_instrumensSpec is GuitarSpec && item.InstrumensSpec is GuitarSpec)
                {
                    GuitarSpec guitarSpec   = item.InstrumensSpec as GuitarSpec;
                    GuitarSpec m_guitarSpec = m_instrumensSpec as GuitarSpec;
                    //如果说这个类型是一致的,所以对比一下二者的NumString属性
                    if (m_guitarSpec.NumString == guitarSpec.NumString)
                    {
                        myList.Add(guitarSpec);
                    }
                }
                else if (m_instrumensSpec is PianoSpec && item.InstrumensSpec is PianoSpec)
                {
                    PianoSpec pianoSpec   = item.InstrumensSpec as PianoSpec;
                    PianoSpec m_pianoSpec = m_instrumensSpec as PianoSpec;
                    if (m_pianoSpec.Style == pianoSpec.Style)
                    {
                        myList.Add(pianoSpec);
                    }
                }
            }
            return(myList);
        }
Esempio n. 2
0
        public void DispInstruments()
        {
            foreach (var item in Instruments_List)
            {
                Console.WriteLine("The SerialNumber :{0},\nThe Price {1},\n", item.SerialNumber, item.Price);

                InstrumentsSpec instrumensSpec = item.InstrumensSpec as InstrumentsSpec;

                Console.WriteLine("Model:{0},\nType:{1},\nBackWood:{2},\nTopWood:{3},\n,Builder:{4},\nType:{5},\n", instrumensSpec.Model, instrumensSpec.Type, instrumensSpec.BackWood, instrumensSpec.TopWood, instrumensSpec.Builder, instrumensSpec.Type);

                if (item.InstrumensSpec is GuitarSpec)
                {
                    GuitarSpec guitarSpec = item.InstrumensSpec as GuitarSpec;
                    Console.WriteLine("String Number of Guitar:{0},\n", guitarSpec.NumString);
                }
                else if (item.InstrumensSpec is PianoSpec)
                {
                    PianoSpec pianoSpec = item.InstrumensSpec as PianoSpec;
                    Console.WriteLine("Style of Piano:{0},\n", pianoSpec.Style);
                }
                Console.WriteLine("__________________________________");
            }
        }
Esempio n. 3
0
 public bool Match(InstrumentsSpec instrumensSpec1, InstrumentsSpec instrumensSpec2)
 {
     if (instrumensSpec1.BackWood != instrumensSpec2.BackWood)
     {
         return(false);
     }
     if (instrumensSpec2.Builder != instrumensSpec1.Builder)
     {
         return(false);
     }
     if (instrumensSpec2.TopWood != instrumensSpec1.TopWood)
     {
         return(false);
     }
     if (instrumensSpec2.Model != instrumensSpec1.Model)
     {
         return(false);
     }
     if (instrumensSpec2.Type != instrumensSpec1.Type)
     {
         return(false);
     }
     return(true);
 }
Esempio n. 4
0
 public Guitar(string serialNumber, double price, String_Enum numString, InstrumentsSpec instrumensSpec) : base(serialNumber, price, instrumensSpec)
 {
 }
Esempio n. 5
0
 public Piano(string serialNumber, double price, Style_Enum a, InstrumentsSpec instrumensSpec) : base(serialNumber, price, instrumensSpec)
 {
 }
Esempio n. 6
0
 public Instruments(string serialNumber, double price, InstrumentsSpec instrumensSpec)
 {
     this.instrumensSpec = instrumensSpec;
     this.price          = price;
     this.serialNumber   = serialNumber;
 }