Question
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
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
Answers
There are no human answers yet.
Answered by
GPT 3.5
This code defines an interface `IPayable` with a method `GetFigure()` that returns a double. Two classes, `Invoice` and `Employee`, implement this interface.
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.
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.
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.