72 532
Assignments Done
98,9%
Successfully Done
In April 2019

Answer to Question #47552 in C# for rabia

Question #47552
Design custom exception Handlers for a boiler class.Throw the custom exceptionBoilerException when the pressure is more than 2000 units or less than 500 units.It should have the following Members and Methods.
Members: double pressure
Methods: void Increase()
void Decrease()
Expert's answer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace C_Sharp_Test
{
class Boiler
{
public const long MAxPressure = 2000;
public const long MINPressure = 500;
public Boiler()
{
pressure = (MAxPressure + MINPressure) / 2;
}
void Increase()
{
pressure++;
if (pressure > MAxPressure) throw new BoilerException("Too high pressure");
}

void Decrease()
{
pressure--;
if (pressure < MINPressure) throw new BoilerException("Too low pressure");
}
double pressure;
}
class BoilerException : Exception
{
public BoilerException()
: base()
{ }
public BoilerException(string message)
: base(message)
{ }
public BoilerException(string message, Exception innerException)
: base(message, innerException)
{ }
}

}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions