Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5
- using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions;
- namespace Rextester {
- public interface Geo {
- double arie(); double perimetru(); string nume{get;}
- } public class Cerc : Geo { double r;
- string forma="cerc"; public string nume{ get{ return forma; } } public double arie() {
- return r*r*System.Math.PI; } public double perimetru() {
- return 2*r*System.Math.PI; } public Cerc (double x) {
- r=x; } } public class Patrat : Geo {
- double l; string forma="patrat";
- public string nume{
- get{ return forma; } } public double arie() {
- return l*l; } public double perimetru() {
- return 4*l; } public Patrat(double x) {l=x;}
- } public class Program {
- static void Print(Geo I){
- Console.WriteLine("Perimetru {2}: {0:#.##} Arie {2}: {1:#.##}" ,I.perimetru(),I.arie(),I.nume);
- } public static void Main(string[] args) {
- Cerc o = new Cerc(5); Patrat abcd = new Patrat(4); Print(abcd); Print(o);
- } } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement