示例#1
0
        private static void testAbstractFurniture()
        {
            Console.WriteLine("\n# testAbstractFurniture()");
            AbstractFurniture table = new Table("Tango", Room.Kitchen, Material.Oak, new Size(80, 90, 100), 120, 4, false, true);
            Console.WriteLine(table);
            AbstractFurniture wardrobe = new Wardrobe("John", Room.Bedroom, Material.CherryTree, new Size(50, 160, 90), 180, 3, DoorType.Sliding, true, false);
            Console.WriteLine(wardrobe);
            AbstractFurniture bed = new Bed("Foxtrot", Room.LivingRoom, Material.Pine, new Size(100, 45, 210), 230, Mattress.Healthy, false, true, false);
            Console.WriteLine(bed);

            Program.sellFurniture(table, 1);
            Program.sellFurniture(wardrobe, 2);
            Program.sellFurniture(bed, 1);
        }
示例#2
0
文件: Bed.cs 项目: davidbedok/oeprog2
 public bool Equals(Bed that)
 {
     if ((object)that == null)
     {
         return false;
     }
     if (base.Equals(that))
     {
         if (that.mattress == this.mattress && that.doubleSize == this.doubleSize && that.compactSize == this.compactSize && that.builtInLamp == this.builtInLamp)
         {
             return true;
         }
     }
     return false;
 }
示例#3
0
        private static void testEqualsBed()
        {
            Console.WriteLine("\n# testEqualsBed()");
            // one, two and five are equal
            // three differs one base field
            // four differs one not-base field
            Bed one = new Bed("Foxtrot", Room.LivingRoom, Material.Pine, new Size(100, 45, 210), 230, Mattress.Healthy, false, true, false);
            Bed two = new Bed("Foxtrot", Room.LivingRoom, Material.Pine, new Size(100, 45, 210), 230, Mattress.Healthy, false, true, false);

            Bed three = new Bed("Foxtrot", Room.LivingRoom, Material.CherryTree, new Size(100, 45, 210), 230, Mattress.Healthy, false, true, false);
            Bed four = new Bed("Foxtrot", Room.LivingRoom, Material.Pine, new Size(100, 45, 210), 230, Mattress.Comfortable, false, true, false);

            Bed five = new Bed("Foxtrot", Room.LivingRoom, Material.Pine, new Size(100, 45, 210), 230, Mattress.Healthy, false, true, false);

            Debug.Assert(!one.Equals(null), "error (implementation bug)");
            Debug.Assert(!one.Equals(new Random()), "error (implementation bug)");

            Debug.Assert(one.Equals(two), "error (implementation bug)");
            Debug.Assert(two.Equals(one), "error (implementation bug)");
            Debug.Assert(two.Equals(five), "error (implementation bug)");
            Debug.Assert(one.Equals(five), "error (implementation bug)");

            Debug.Assert(one.Equals(three) == three.Equals(one), "error (implementation bug)");

            Debug.Assert(!one.Equals(three), "error (implementation bug)");
            Debug.Assert(!one.Equals(four), "error (implementation bug)");
            Debug.Assert(!three.Equals(one), "error (implementation bug)");
            Debug.Assert(!two.Equals(four), "error (implementation bug)");
        }