Create a class that has 3 properties: a job number, estimated hours, and price for the job. You need to use an auto-implemented property for the job number, and provide get and set accessors for estimated hours. The price field value is calculated as estimated hours times $45 whenever the hours values is set, and the Price property is read-only. Create a constructor that requires parameters for job number and estimated hours only. Also, include a method that overrides the class’s ToString() method and returns a string that contains the class name (using GetType()) and the job’s data field values. The class has a child class named that includes an auto-implemented property, which holds an additional charge for the job. For the class, you need to create a constructor that accepts job number, estimated hours, and additional charge. Also, override the class’s ToString() method and return a string that contains the class name and all data field values, as well as the total price (i.e., price + additional charge). Finally, create an application class named that instantiates one object and one

In order to create the desired class, we will define a base class called ‘Job’ with three properties: ‘JobNumber’, ‘EstimatedHours’, and ‘Price’. The ‘JobNumber’ will be an auto-implemented property, meaning it will automatically generate a private backing field behind the scenes. The ‘EstimatedHours’ property will have get and set accessors to allow users to retrieve and update its value. The ‘Price’ field will be calculated as the product of ‘EstimatedHours’ and a fixed rate of $45.

To implement this in code, we will begin by creating the ‘Job’ class as follows:

“`csharp
public class Job
{
public int JobNumber { get; } // Auto-implemented property

private int _estimatedHours;
public int EstimatedHours
{
get { return _estimatedHours; }
set
{
_estimatedHours = value;
Price = _estimatedHours * 45; // Calculate price whenever hours are set
}
}

public decimal Price { get; private set; }

// Constructor that requires job number and estimated hours as parameters
public Job(int jobNumber, int estimatedHours)
{
JobNumber = jobNumber;
EstimatedHours = estimatedHours;
}

// Override the ToString() method to return class name and job data field values
public override string ToString()
{
return string.Format(“{0}: Job number: {1}, Estimated hours: {2}, Price: {3}”,
GetType().Name, JobNumber, EstimatedHours, Price);
}
}
“`

Next, we will create a child class named ‘AdditionalChargeJob’ that inherits from the ‘Job’ class to include an additional property for the extra charge. In addition to the base class properties and methods, the ‘AdditionalChargeJob’ class will have an ‘AdditionalCharge’ property and an overridden ‘ToString()’ method that includes the total price calculated by adding the base price and additional charge.

The ‘AdditionalChargeJob’ class can be implemented as follows:

“`csharp
public class AdditionalChargeJob : Job
{
public decimal AdditionalCharge { get; set; } // Auto-implemented property for additional charge

// Constructor that accepts job number, estimated hours, and additional charge
public AdditionalChargeJob(int jobNumber, int estimatedHours, decimal additionalCharge)
: base(jobNumber, estimatedHours)
{
AdditionalCharge = additionalCharge;
}

// Override the ToString() method to return class name, job data field values, and total price
public override string ToString()
{
decimal totalPrice = Price + AdditionalCharge;
return string.Format(“{0}: Job number: {1}, Estimated hours: {2}, Price: {3}, Additional charge: {4}, Total price: {5}”,
GetType().Name, JobNumber, EstimatedHours, Price, AdditionalCharge, totalPrice);
}
}
“`

Finally, we can create an application class to demonstrate the usage of the ‘Job’ and ‘AdditionalChargeJob’ classes. The application class will instantiate one object of each class and display their information using the ‘ToString()’ method.

The application class can be implemented as follows:

“`csharp
public class Program
{
public static void Main()
{
Job job = new Job(1, 8);
AdditionalChargeJob additionalChargeJob = new AdditionalChargeJob(2, 12, 100);

Console.WriteLine(job.ToString());
Console.WriteLine(additionalChargeJob.ToString());
}
}
“`

When executed, the program will display the details of the ‘Job’ object and the ‘AdditionalChargeJob’ object, showcasing the functionality of the defined classes.

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.


Click Here to Make an Order Click Here to Hire a Writer