using System;
namespace IPayable
{
public interface IPayable
{
double GetFigure();
}
public class Invoice : IPayable
{
private double amount;
private int invoiceNum;
public double GetFigure()
{
double amount = 0;
return amount;
}
}
public class Employee : IPayable
{
private int id;
private string name;
private int age;
public double GetFigure()
{
throw new NotImplementedException();
}
}
public class SalaredEmployee(double salary) : Employee
{
private double salary = salary;
public double GetFigure(double amount)
{
return salary;
}
}
public class Program
{
public static void Main()
{
//create objects
Invoice invoice = new Invoice();
Employee employee = new Employee();
}
}
}
explain what is happening in this code
1 answer
The `Invoice` class has private fields for amount and invoice number, and it implements the `GetFigure()` method by returning the amount.
The `Employee` class has private fields for ID, name, and age, and it currently throws a `NotImplementedException` in the `GetFigure()` method.
There is an attempt at defining a subclass `SalaredEmployee` of `Employee` that takes a salary as a parameter in the constructor, but it has some errors in the syntax. It should be `SalaredEmployee : Employee` instead of `SalaredEmployee(double salary) : Employee`.
Finally, in the `Program` class, objects of `Invoice` and `Employee` are created but not used in any further operations.