Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your first project was so successful that your company has asked you to add a few enhancements (feature requests) to the existing application. Now that

Your first project was so successful that your company has asked you to add a few enhancements (feature requests) to the existing application. Now that you know about abstract classes and interfaces, it's the perfect opportunity to use the concepts.

Alter your application to complete the following:

  1. Calculate the due date based on the invoice date. The due dates for personal accounts and business accounts are calculated differently. Personal accounts are due 30 days from the invoice date, and business accounts are due 60 days from the invoice date.

    Use an abstract method to calculate the due date. Remove the old DueDate property because you no longer want users to be able to set this property. Remember, when you mark a method as abstract, you will need to mark the class as abstract too!

    To calculate days, use the DateTime.AddDays method.

  2. Create an interface named IPayMyBill. It needs a single method called Pay. Implement the interface in both your personal and business account classes. This method sets the amount due to 0.
  3. In your application, create an instance of each account type you defined. Set the properties to the following values:

    FirstName Your first name LastName Your last name InvoiceDate The current date AmountDue Any decimal value you would like BusinessName Any string value you would like BusinessAddress Any string value you would like

Output the following to the console:

Name Amount Due Due Date

Then call the Pay method on each instance of classes (you do not need to output any additional information after calling the Pay method).

An example of the output would be:

Name:John Smith AmountDue:$900 Due:12/1/2016 Name:AAA AmountDue:$9000 Due:1/15/2017

This is my original code

Account.cs

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace Account { public class Personal : Account { //Variables public string firstName; public string lastName; public DateTime invoiceDate;

DateTime date1 = new DateTime(2020, 1, 1); DateTime date2 = new DateTime(2019, 1, 11);

public Personal() { firstName = "Aaron"; lastName = "Joseph"; invoiceDate = date2; dueDate = date1; moneyDue = 900; }

public void personalAccount() {

Console.WriteLine("Name: " + firstName + lastName + " Invoice Date: " + invoiceDate + " Due Date: " + dueDate + " Amount Due: " + moneyDue);

}

} }

Business.cs

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace Account { public class Business : Account {

public string businessName; public string businessAddress;

DateTime date3 = new DateTime(2020, 8, 8);

public Business() { businessName = "Pristine Auction"; businessAddress = "1095 E Salter Dr, Phoenix, AZ 85024"; dueDate = date3; moneyDue = 1000000000; }

public void businessAccount() {

Console.WriteLine("Business Name: " + businessName + " Business Address: " + businessAddress + " Due Date: " + dueDate + " Amount Due: " + moneyDue);

}

} }

Personal.cs

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace Account { public class Personal : Account { //Variables public string firstName; public string lastName; public DateTime invoiceDate;

DateTime date1 = new DateTime(2020, 1, 1); DateTime date2 = new DateTime(2019, 1, 11);

public Personal() { firstName = "Aaron"; lastName = "Joseph"; invoiceDate = date2; dueDate = date1; moneyDue = 900; }

public void personalAccount() {

Console.WriteLine("Name: " + firstName + lastName + " Invoice Date: " + invoiceDate + " Due Date: " + dueDate + " Amount Due: " + moneyDue);

}

} }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Administration The Essential Reference

Authors: Brian Laskey, David Kreines

1st Edition

1565925165, 978-1565925168

More Books

Students also viewed these Databases questions