Create the following hierarchy using C#. Create interface IPayable which has a method – GetPaymentAmount(). Create a class Invoice which inherits from IPayable and has following instance data: quantity and price per item. Create class Employee ( has first name, last name and Social Security Number ) and Salaried Employee ( Weekly Salary ) as shown in the hierarchy. Test all classes by creating objects and making use of Interface Polymorphism.
Screenshot
Program
using System;
namespace InterfaceInheritanceInCSharp
{
//Create an interface with a method
public interface IPayable
{
double
GetPaymentAmount();
}
//Create class that implements inteface
public class Invoice : IPayable
{
//Attributes
int quantity;
double price;
//Construtor
public Invoice(int
quant,double pr)
{
quantity = quant;
price = pr;
}
//Implementation of
inteface
public double
GetPaymentAmount()
{
return quantity * price;
}
}
//Create class that implements inteface
public class Employee : IPayable
{
//Attributes
string firstName;
string lastName;
string ssn;
//Constructor
public Employee(string
f, string l, string s)
{
firstName = f;
lastName = l;
ssn = s;
}
//Interface
function
public virtual double
GetPaymentAmount()
{
throw new NotImplementedException();
}
}
//Create a class that extends Employee
public class SalriedEmployee: Employee
{
//Attribute
double
weeklySalary;
//Constructor
public
SalriedEmployee(string fName,string lName,string ssn,double
sal):base(fName, lName, ssn)
{
weeklySalary = sal;
}
//Implement
public override double
GetPaymentAmount()
{
return weeklySalary;
}
}
//Test
class Program
{
static void
Main(string[] args)
{
//Object of Salried employee
SalriedEmployee emp = new SalriedEmployee("Mugal", "Empire",
"MM123456", 450);
//Display weekly salary
Console.WriteLine("Weekly salary = $" +
emp.GetPaymentAmount());
//Object of invoice class
Invoice invoice = new Invoice(10, 12.5);
//Display invoce total
Console.WriteLine("Invoice of item = $"
+invoice.GetPaymentAmount());
}
}
}
Output
Weekly salary = $450
Invoice of item = $125
Create the following hierarchy using C#. Create interface IPayable which has a method – GetPaymentAmount(). Create...
In Java
Create an interface called
Amount
that includes a method called
setPrice
().
Create an abstract class named
Book
that inherits from the interface Amount. Include a String field
for
the book’s
title
and a double field for the book’s
Price
. Within the class, include a constructor that
requires the book title and add
two getter methods
— one that returns the title and one that returns the
price. Include an abstract method named
setPrice
().
Create a...
ASAP Please. Python Program Description Create an object-oriented program that allows you to enter data for employees. Specifications Create an abstract Employee class that provides private attributes for the first name, last name, email address, and social security number. This class should provide functions that set and return the employee’s first name, last name, email address, and social security number. This class has a function: get_net_income which returns 0. Create a Manager class that inherits the Employee class. This class...
Java program. Code the following interfaces, implement them, and use the interface as a parameter, respectively: a. An interface called Printable with a void print() method. b. An interface called EmployeeType with FACULTY and CLASSIFIED integer data. The value of FACULTY is 1 and CLASSIFIED is 2. a. A class called Employee to implement the two interfaces. Its constructor will initialize three instance data as name, employeeType, and salary. Implementation of method print() will display name, employeeType, and salary; salary...
Create a crows foot erd using a specialization hierarchy if appropriate. Granite sales company keeps information on its employees and the departments in which they work. For each department, the department name,internal mailbox server, and office phone extension are kept. A department can have many assigned employees, and each employee is assigned to only one department. Employees can be salaried, hourly, or work on contract. All employees are assigned an employee number, which is kept along with the employee's name...
Java code for the following inheritance hierarchy figure..
1. Create class Point, with two private
instance variables x and y that represented for the coordinates for
a point.
Provide constructor for initialising two instance variables.
Provide set and get methods
for each instance variable,
Provide toString method to return formatted
string for a point coordinates.
2. Create class Circle, its inheritance from
Point.
Provide a integer private
radius instance variable.
Provide constructor to
initialise the center coordinates and radius for...
Define an interface FarmAnimal that contains two methods: getName() and talk(), each returns a string. Declare an abstract class FarmAnimalBase that implements the interface FarmAnimal. In the class FarmAnimalBase, define a private final instance variable name (type: String), a public constructor that initializes the value of the instance variable name, and a public method getName() that returns the value of the instance variable name. Note that we do not implement the method talk() declared in the interface FarmAnimal, that’s the...
This is for Java Programming Please use comments Customer and Employee data (15 pts) Problem Description: Write a program that uses inheritance features of object-oriented programming, including method overriding and polymorphism. Console Welcome to the Person Tester application Create customer or employee? (c/e): c Enter first name: Frank Enter last name: Jones Enter email address: frank44@ hot mail. com Customer number: M10293 You entered: Name: Frank Jones Email: frank44@hot mail . com Customer number: M10293 Continue? (y/n): y Create customer...
Answer the following: 1. Create a Class Car with the following instance variables: model (String), Brand (String), maxspeed (double) Note: use encapsulation (all variables are private). (3 Marks) 2. Create a non-default constructor for Class Car which takes 3 parameters. (2 Marks) 3. Create a get and set methods for instance variable model variable only. (2 Marks) 4. Create PrintInfo() method which prints all three instance variables. (2 Marks) 5. Create a subclass GasCar with instance variable TankSize (double).. (2...
java.
Question 3: The payment transaction scenario could be represented by the following hierarchy: Payments VISA MASTERCARD Paypal Create Payments as a superclass and VISA, MASTERCARD, PAYPAL as subclasses Create an interface PaymentsInterface with one method called payment Info. Create classes VISA, MASTERCARD, PAYPAL that implement Payments For each of the three classes (VISA, MASTERCARD, PAYPAL), create one constructor Constructors are used to create objects with initial balance with US dollars (USD). The interface class method "paymentinfo" should be overridden...
Create a Java application, that support the following: Create an Employee class, which holds following information: Employee First Name Employee Last Name Employee Phone Number Employee Address Employee id Employee Title Employee salary Create an application that uses the Employee class Constructors –Getters and setters A minimum of 3 constructors including default constructor equals() method Helper methods toString() method Create an array of 5 Employee objects Use a Scanner to read in 5 employee information Change 2 employees information (3-items...