Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Rectangle rectangle = new Rectangle(120, 150, "blue");
- Console.WriteLine(rectangle.ToString());
- Console.ReadKey();
- }
- }
- }
- -------------------------------------------------
- //Osztályok
- _________________________________________________
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- internal abstract class Shape
- {
- private bool isHoley;
- private string color;
- public string name;
- protected Shape(bool isHoley, string color)
- {
- this.isHoley = isHoley;
- this.color = color;
- }
- protected Shape(string color)
- {
- this.color = color;
- this.isHoley = false;
- }
- public string Color { get { return this.color; } set { value = this.color; } }
- public void MakeHolly()
- {
- this.isHoley = true;
- }
- public abstract double Perimeter();
- public abstract double Area();
- public override string ToString()
- {
- return $"{this.color} {this.isHoley} {this.Perimeter()} {this.Area()}";
- }
- public override bool Equals(object obj)
- {
- if (obj is Shape)
- {
- Shape other = obj as Shape;
- if (this.color == other.color)
- {
- return true;
- }
- }
- return false;
- }
- public virtual void KillShape()
- {
- Console.WriteLine("Meghaltam!");
- }
- }
- }
- -------------------------------------------------
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- internal class Rectangle : Shape
- {
- public new string name;
- private int height;
- private int width;
- public int Height { get { return height; } set { this.height = value; } }
- public int Width { get { return width; } set { this.width = value; } }
- public Rectangle(int width, int height, string color) : base(color)
- {
- this.height = height;
- this.width = width;
- }
- public Rectangle(int width, int height, bool isHoley, string color) : base(isHoley, color)
- {
- this.height = height;
- this.width = width;
- }
- public override string ToString()
- {
- return $"Teglalap: {base.ToString()}";
- }
- public override double Area()
- {
- return this.width * this.height;
- }
- public override double Perimeter()
- {
- return 2 * (this.width+this.height);
- }
- public override void KillShape()
- {
- Console.WriteLine("Rectangle Meghalt!");
- }
- }
- }
- --------------------------------------------------------
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- internal class Square : Shape
- {
- public Square(int width, int height, string color) : base(color)
- {
- }
- public Square(int width, int height, bool isHoley, string color) : base(isHoley, color)
- {
- }
- public override double Area()
- {
- throw new NotImplementedException();
- }
- public override double Perimeter()
- {
- throw new NotImplementedException();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement