HyperPixel
HyperPixel
CC#
Created by HyperPixel on 3/5/2025 in #help
Can someone tell me what am i doing wrong?
just straight goes to end the code
15 replies
CC#
Created by HyperPixel on 3/5/2025 in #help
Can someone tell me what am i doing wrong?
and it wont work
15 replies
CC#
Created by HyperPixel on 3/5/2025 in #help
Can someone tell me what am i doing wrong?
i put that if its not zero and smaller than capacity it should ask to add or not and all that
15 replies
CC#
Created by HyperPixel on 3/5/2025 in #help
Can someone tell me what am i doing wrong?
what should i do with it?
15 replies
CC#
Created by HyperPixel on 3/5/2025 in #help
Can someone tell me what am i doing wrong?
No description
15 replies
CC#
Created by HyperPixel on 3/5/2025 in #help
Can someone tell me what am i doing wrong?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

namespace ObjectsProject
{

internal class Bucket
{
private int capacity;
private double currentAmount;

public Bucket(int capacity, double currentAmount)
{
this.capacity = capacity;
currentAmount = 0.0;
}

public void SetCapacity(int capacity)
{
this.capacity = capacity;
}

public void SetCurrentAmount(double currentAmount)
{
this.currentAmount = currentAmount;
}

public void EmptyAll()
{
this.currentAmount = 0.0;
}

public void IsEmpty()
{
if (this.currentAmount == 0)
{
Console.WriteLine("true");
}
else
{
Console.WriteLine("false");
}
}

public void Empty()
{
if (currentAmount > 0)
{
currentAmount = 0;
}
}

public void FillAll()
{
if (capacity > currentAmount)
{
this.capacity = (int)this.currentAmount;
}
else
{
Console.WriteLine("The bucket is already full!");
}
}
public void IsFill()
{
if (capacity == currentAmount)
{
Console.WriteLine("True");
}
else
{
Console.WriteLine("False");
}
}

public void Fill()
{
if (currentAmount > 0)
{
currentAmount = capacity;
}
}

public int GetCapacity()
{
return capacity;
}

public double GetCurrentAmount()
{
return currentAmount;
}


public void PourInto(Bucket otherBucket)
{
while (this.currentAmount > 0 && otherBucket.currentAmount < otherBucket.capacity)
{
this.currentAmount--;
otherBucket.currentAmount++;
}
}

public bool Equals(Bucket otherBucket)
{
return this.capacity == otherBucket.capacity && this.currentAmount == otherBucket.currentAmount;
}
public override string ToString()
{
return $"Bucket with capacity {capacity} and current amount {currentAmount}";
}


}



}

using ObjectsProject;
using System;

class Program
{
static void Main()
{
Console.Write("Enter bucket capacity: ");
int capacity = int.Parse(Console.ReadLine());

Console.Write("Enter current amount: ");
double currentAmount = double.Parse(Console.ReadLine());

Bucket bucket = new Bucket(capacity, currentAmount);

while (bucket.GetCurrentAmount() > 0 && bucket.GetCurrentAmount() < bucket.GetCapacity())
{
Console.Write("Do you want to (add) or (remove) water? ");
string action = Console.ReadLine().ToLower();

Console.Write("Enter amount: ");
double amount = double.Parse(Console.ReadLine());

if (action == "add")
{
bucket.SetCurrentAmount(Math.Min(bucket.GetCurrentAmount() + amount, bucket.GetCapacity()));
}
else if (action == "remove")
{
bucket.SetCurrentAmount(Math.Max(bucket.GetCurrentAmount() - amount, 0));
}
else
{
Console.WriteLine("Invalid option. Please enter 'add' or 'remove'.");
}

Console.WriteLine(bucket.ToString());
}

Console.WriteLine("Bucket is either empty or full.");
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

namespace ObjectsProject
{

internal class Bucket
{
private int capacity;
private double currentAmount;

public Bucket(int capacity, double currentAmount)
{
this.capacity = capacity;
currentAmount = 0.0;
}

public void SetCapacity(int capacity)
{
this.capacity = capacity;
}

public void SetCurrentAmount(double currentAmount)
{
this.currentAmount = currentAmount;
}

public void EmptyAll()
{
this.currentAmount = 0.0;
}

public void IsEmpty()
{
if (this.currentAmount == 0)
{
Console.WriteLine("true");
}
else
{
Console.WriteLine("false");
}
}

public void Empty()
{
if (currentAmount > 0)
{
currentAmount = 0;
}
}

public void FillAll()
{
if (capacity > currentAmount)
{
this.capacity = (int)this.currentAmount;
}
else
{
Console.WriteLine("The bucket is already full!");
}
}
public void IsFill()
{
if (capacity == currentAmount)
{
Console.WriteLine("True");
}
else
{
Console.WriteLine("False");
}
}

public void Fill()
{
if (currentAmount > 0)
{
currentAmount = capacity;
}
}

public int GetCapacity()
{
return capacity;
}

public double GetCurrentAmount()
{
return currentAmount;
}


public void PourInto(Bucket otherBucket)
{
while (this.currentAmount > 0 && otherBucket.currentAmount < otherBucket.capacity)
{
this.currentAmount--;
otherBucket.currentAmount++;
}
}

public bool Equals(Bucket otherBucket)
{
return this.capacity == otherBucket.capacity && this.currentAmount == otherBucket.currentAmount;
}
public override string ToString()
{
return $"Bucket with capacity {capacity} and current amount {currentAmount}";
}


}



}

using ObjectsProject;
using System;

class Program
{
static void Main()
{
Console.Write("Enter bucket capacity: ");
int capacity = int.Parse(Console.ReadLine());

Console.Write("Enter current amount: ");
double currentAmount = double.Parse(Console.ReadLine());

Bucket bucket = new Bucket(capacity, currentAmount);

while (bucket.GetCurrentAmount() > 0 && bucket.GetCurrentAmount() < bucket.GetCapacity())
{
Console.Write("Do you want to (add) or (remove) water? ");
string action = Console.ReadLine().ToLower();

Console.Write("Enter amount: ");
double amount = double.Parse(Console.ReadLine());

if (action == "add")
{
bucket.SetCurrentAmount(Math.Min(bucket.GetCurrentAmount() + amount, bucket.GetCapacity()));
}
else if (action == "remove")
{
bucket.SetCurrentAmount(Math.Max(bucket.GetCurrentAmount() - amount, 0));
}
else
{
Console.WriteLine("Invalid option. Please enter 'add' or 'remove'.");
}

Console.WriteLine(bucket.ToString());
}

Console.WriteLine("Bucket is either empty or full.");
}
}
15 replies