Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. //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
  2. using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions;
  3. namespace Rextester {
  4. public interface Geo {
  5. double arie(); double perimetru(); string nume{get;}
  6. } public class Cerc : Geo { double r;
  7. string forma="cerc"; public string nume{ get{ return forma; } } public double arie() {
  8. return r*r*System.Math.PI; } public double perimetru() {
  9. return 2*r*System.Math.PI; } public Cerc (double x) {
  10. r=x; } } public class Patrat : Geo {
  11. double l; string forma="patrat";
  12. public string nume{
  13. get{ return forma; } } public double arie() {
  14. return l*l; } public double perimetru() {
  15. return 4*l; } public Patrat(double x) {l=x;}
  16. } public class Program {
  17. static void Print(Geo I){
  18. Console.WriteLine("Perimetru {2}: {0:#.##} Arie {2}: {1:#.##}" ,I.perimetru(),I.arie(),I.nume);
  19. } public static void Main(string[] args) {
  20. Cerc o = new Cerc(5); Patrat abcd = new Patrat(4); Print(abcd); Print(o);
  21. } } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement