// Constructors
  public Compound( string name ) : base( name )
  {
    // Adaptee
    bank = new ChemicalDatabank();

    // Adaptee request methods
    boilingPoint = bank.GetCriticalPoint( name, "B" );
    meltingPoint = bank.GetCriticalPoint( name, "M" );
    molecularWeight = bank.GetMolecularWeight( name );
    molecularFormula = bank.GetMolecularStructure( name );
  }
        public override void Display()
        {
            // The Adaptee
            chemicalDatabank = new ChemicalDatabank();

            molecularFormula = chemicalDatabank.GetMolecularStructure(chemical);
            boilingPoint     = chemicalDatabank.GetCriticalPoint(chemical);
            Console.WriteLine("---Adapter magic--");
            base.Display();
            Console.WriteLine("Formula: {0}", molecularFormula);
            Console.WriteLine("Boiling Point: {0}", boilingPoint);
        }
 public override void Display()
 {
     // The Adaptee
     _bank             = new ChemicalDatabank();
     _boilingPoint     = _bank.GetCriticalPoint(_chemical, "B");
     _meltingPoint     = _bank.GetCriticalPoint(_chemical, "M");
     _molecularWeight  = _bank.GetMolecularWeight(_chemical);
     _molecularFormula = _bank.GetMolecularStructure(_chemical);
     //TODO 「★抽象メソッドの処理をオーバーライドし、その処理の中で元処理を呼び出す」
     base.Display();
     Console.WriteLine(" Formula: {0}", _molecularFormula);
     Console.WriteLine(" Weight : {0}", _molecularWeight);
     Console.WriteLine(" Melting Pt: {0}", _meltingPoint);
     Console.WriteLine(" Boiling Pt: {0}", _boilingPoint);
 }
Beispiel #4
0
        public static void Main()
        {
            var water = new ChemicalDatabank();

            System.Console.WriteLine(water.GetCriticalPoint("water", "M"));

            //ICompound water = new RichCompound("Water");
            //water.Display();

            //ICompound benzene = new RichCompound("Benzene");
            //benzene.Display();

            //ICompound ethanol = new RichCompound("Ethanol");
            //ethanol.Display();
        }
Beispiel #5
0
    public override void Display()
    {
        _bank = new ChemicalDatabank();

        _boilingPoint     = _bank.GetCriticalPoint(_chemical, "B");
        _meltingPoint     = _bank.GetCriticalPoint(_chemical, "M");
        _molecularWeight  = _bank.GetMolecularWeight(_chemical);
        _molecularFormula = _bank.GetMolecularStructure(_chemical);

        base.Display();
        Console.WriteLine(" Formula: {0}", _molecularFormula);
        Console.WriteLine(" Weight : {0}", _molecularWeight);
        Console.WriteLine(" Melting Pt: {0}", _meltingPoint);
        Console.WriteLine(" Boiling Pt: {0}", _boilingPoint);
    }
        public override void Display()
        {
            //The Adaptee
            _bank = new ChemicalDatabank();

            _bolingPoint       = _bank.GetCriticalPoint(_chemicalName, ChemicalPoints.BOLING_POINT);
            _meltingPoint      = _bank.GetCriticalPoint(_chemicalName, ChemicalPoints.MELTING_POINT);
            _molecularWeight   = _bank.GetMolecularWeight(_chemicalName);
            _molercuralFormula = _bank.GetMolecularStructure(_chemicalName);

            base.Display();
            Console.WriteLine($"\tFormula: {_molercuralFormula}");
            Console.WriteLine($"\tWeight: {_molecularWeight}");
            Console.WriteLine($"\tMelting Point: {_bolingPoint}");
            Console.WriteLine($"\tBoiling Point: {_meltingPoint}");
        }
        public override void Display()
        {
            // The Adaptee
            bank = new ChemicalDatabank();

            boilingPoint     = bank.GetCriticalPoint(chemical, "B");
            meltingPoint     = bank.GetCriticalPoint(chemical, "M");
            molecularWeight  = bank.GetMolecularWeight(chemical);
            molecularFormula = bank.GetMolecularStructure(chemical);

            base.Display();
            Console.WriteLine($"   Formula: {molecularFormula}");
            Console.WriteLine($"   Weight : {molecularWeight}");
            Console.WriteLine($"   Melting Pt: {meltingPoint}");
            Console.WriteLine($"   Boiling Pt: {boilingPoint}");
        }
Beispiel #8
0
        public RichCompound(Chemical chemical)
        {
            Chemical = chemical;

            Bank = new ChemicalDatabank();
        }