Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Geo
- { class Rectangle
- { protected double width;
- protected double height;
- public double Width{get{return width;}}
- public double Height{get{return height;}}
- public Rectangle(double width, double height)
- { if(width > 0 && height > 0)
- { this.width = width;
- this.height = height;
- }
- else throw new ArgumentOutOfRangeException("bad data");
- }
- }
- class Square : Rectangle
- { public Square(double size):base(size, size){} }
- class MutableRectangle : Rectangle
- { public MutableRectangle(double width, double height) : base(width, height){}
- public void setWidth(double width)
- { if(width>0) this.width = width;
- else throw new ArgumentOutOfRangeException("bad data");
- }
- public void setHeight(double height)
- { if(height>0) this.height = height;
- else throw new ArgumentOutOfRangeException("bad data");
- }
- }
- class MutableSquare : Square
- { public MutableSquare(double size):base(size){}
- public void setSize(double size)
- { if(size>0)
- { this.width=size;
- this.height=size;
- }
- else throw new ArgumentOutOfRangeException("bad data");}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement