-
Define abstract class
Shape
with only one abstract methodCalculateSurface()
and fieldswidth
andheight
. Define two new classesTriangle
andRectangle
that implement the virtual method and return the surface of the figure (height * width
for rectangle andheight * width / 2
for triangle). Define classCircle
and suitable constructor so that at initialization height must be kept equal to width and implement theCalculateSurface()
method. Write a program that tests the behavior of theCalculateSurface()
method for different shapes (Circle
,Rectangle
,Triangle
) stored in an array. -
A
bank
holds different types of accounts for its customers:deposit
accounts,loan
accounts andmortgage
accounts. Customers could be individuals or companies.All accounts have customer, balance and interest rate (monthly based). Deposit accounts are allowed to deposit and with draw money. Loan and mortgage accounts can only deposit money.
All accounts can calculate their interest amount for a given period (in months). In the common case its is calculated as follows:
number_of_months * interest_rate
.Loan accounts have no interest for the first 3 months if are held by individuals and for the first 2 months if are held by a company.
Deposit accounts have no interest if their balance is positive and less than 1000.
Mortgage accounts have 1/2 interest for the first 12 months for companies and no interest for the first 6 months for individuals.
Your task is to write a program to model the bank system by classes and interfaces. You should identify the classes, interfaces, base classes and abstract actions and implement the calculation of the interest functionality through overridden methods.
-
Define a class
InvalidRangeException<T>
that holds information about an error condition related to invalid range. It should hold error message and a range definition[start ... end]
. Write a sample application that demonstrates theInvalidRangeException<int>
andInvalidRangeException<DateTime>
by entering numbers in the range [1..100] and dates in the range [1.1.1980 ... 31.12.2013].