Advertisement
maxlarin2

1

Mar 11th, 2014
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication4
  7. {
  8.     abstract class Coin
  9.     {
  10.         public double Value { get; private set; }
  11.         protected Coin(double value)
  12.         {
  13.             this.Value = value;
  14.         }
  15.         public abstract double Convert();
  16.     }
  17.     class cent : Coin
  18.     {
  19.         public cent(double val)
  20.             : base(val)
  21.         {
  22.         }
  23.         public override double Convert()
  24.         {
  25.             return base.Value * 30;
  26.         }
  27.         public abstract class Program
  28.         {
  29.             static cent sum(Coin  c1, Coin c2)
  30.             {
  31.                 int ans = c1.Value+c2.Value;
  32.                 return ans;
  33.             }
  34.  
  35.             static void Main(string[] args)
  36.             {
  37.                 Coin c1 = new cent(50.1);
  38.                 Coin c2 = new cent(20);
  39.                 Coin c = sum(c1, c2);
  40.                 Console.WriteLine(c);
  41.             }
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement