/******************************************************************************
Online C# Compiler.
Code, Compile, Run and Debug C# program online.
Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
using System;
class HelloWorld {
static void Test01()
{
Bucket bucket1 = new Bucket(20);
bucket1 = new Bucket(20);
bucket1.Print();
bucket1.SetAmount(7);
bucket1.Print();
//Console.WriteLine(bucket1.amount);
int a = bucket1.GetAmount();
Console.WriteLine("a:{0}", a);
Bucket bucket4 = new Bucket(50, "Red");
bucket4.Print();
Bucket bucket5 = new Bucket(50, "Green",50);
bucket5.Print();
bool b1 = bucket1.IsEmpty();
Console.WriteLine("b1:{0}",b1);
bool b5 = bucket5.IsEmpty();
Console.WriteLine("b5:{0}", b5);
}
static void Main() {
Console.WriteLine("Hello World");
Test01();
}
}
using System;
public class Bucket
{
//صفات
private int c; //capacity
private string color;
private int amount;
//بناء
public Bucket(int c)
{
this.c = c;
this.color = "Blue";
this.amount = 0;
}
public Bucket(int c, string color)
{
this.c = c;
this.color = color;
this.amount = 0;
}
public Bucket(int c, string color, int amount)
{
this.c = c;
this.color = color;
this.amount = amount;
}
//عمليات
public void Print()
{
Console.WriteLine("Print - c:{0}, color:{1}, amount:{2}",this.c, this.color, this.amount);
}
public void PrintLN()
{
Console.WriteLine("PrintLN - c:{0}", this.c);
Console.WriteLine("PrintLN - color:{0}", this.color);
Console.WriteLine("PrintLN - amount:{0}", this.amount);
}
public bool IsEmpty()
{
return ( this.amount ==0);
}
public int GetAmount()
{
return this.amount;
}
public void SetAmount(int amount)
{
this.amount = amount;
}
public bool IsFull()
{
return (this.c == this.amount);
// if (this.c == this.amount)
// return true;
//return false;
}
}