Created
November 19, 2015 23:16
-
-
Save kkrico/7b33dcaa11b2c970ed53 to your computer and use it in GitHub Desktop.
Exercicio de OO pedido em sala dia 19/11/2015. - Daniel Ferreira Ramos <ramos.danielferreira@gmail.com>. Também disponivel em http://1drv.ms/1I2fozC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace FormacaoTalentos.Exercise | |
{ | |
public class Circle : ResizableCircle, IGeometricObject | |
{ | |
// Se quiser fazer com Auto property direto | |
//protected double Radius { get; set; } | |
private double _radius; | |
public double Radius | |
{ | |
get | |
{ | |
return (_radius < 0.0) ? 1.0 : _radius; | |
} | |
set | |
{ | |
_radius = value; | |
} | |
} | |
public Circle(double radius) : base(radius) | |
{ | |
this.Radius = radius; | |
} | |
public double GetPerimeter() | |
{ | |
return this.Radius * 2 * Math.PI; | |
} | |
public double GetArea() | |
{ | |
return Math.Pow(this.Radius, 2) * Math.PI; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace FormacaoTalentos.Exercise | |
{ | |
interface IGeometricObject | |
{ | |
double GetPerimeter(); | |
double GetArea(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace FormacaoTalentos.Exercise | |
{ | |
interface IResizable | |
{ | |
void Resize(int percent); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using FormacaoTalentos.Exercise; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace FormacaoTalentos | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
IGeometricObject a = new Circle(-1.0); | |
Console.WriteLine(a.GetPerimeter()); | |
Console.WriteLine(a.GetArea()); | |
IGeometricObject o = new Circle(0.0); | |
Console.WriteLine(o.GetPerimeter()); | |
Console.WriteLine(o.GetArea()); | |
Circle c = new Circle(10); | |
Console.WriteLine(c.GetPerimeter()); | |
Console.WriteLine(c.GetArea()); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace FormacaoTalentos.Exercise | |
{ | |
public class ResizableCircle : IResizable | |
{ | |
public ResizableCircle(double radius) | |
{ | |
} | |
public void Resize(int percent) | |
{ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment