There are 3 classes in total about a jobs in C#. Complete the missing parts of t
ID: 3736643 • Letter: T
Question
There are 3 classes in total about a jobs in C#. Complete the missing parts of the RushJob class:
1) Job.cs
namespace JobDemo
{
class Job
{
protected double hours;
protected double price;
public const double RATE = 45.00;
public Job(int num, string cust, string desc, double hrs)
{
this.JobNumber = num;
this.Customer = cust;
this.Description = desc;
hours = hrs;
price = hours * RATE;
}
public int JobNumber
{
get; set;
}
public string Customer
{
get; set;
}
public string Description
{
get; set;
}
public double Hours
{
get
{
return hours;
}
set
{
hours = value;
price = hours * RATE;
}
}
public double Price
{
get
{
return price;
}
}
public override string ToString()
{
return (GetType() + " " + JobNumber + " " + Customer + " " +
Description + " " + Hours + " hours @" + RATE.ToString("C") +
" per hour. Total price is " + Price.ToString("C"));
}
public override bool Equals(Object e)
{
if (this.JobNumber == ((Job)e).JobNumber)
return true;
else
return false;
}
public override int GetHashCode()
{
return JobNumber;
}
}
}
2) Program.cs
namespace JobDemo
{
class Program
{
static void Main(string[] args)
{
Job[] jobs = new Job[3];
jobs[0] = new Job(111, "John", "Analyst", 12);
jobs[1] = new Job(112, "Clary", "Programmer", 14.15);
jobs[2] = new Job(113, "Jason", "Developer", 13.15);
Console.WriteLine(jobs[0].ToString());
Console.WriteLine(jobs[1].ToString());
Console.WriteLine(jobs[2].ToString());
if (jobs[0].Equals(jobs[1]))
{
Console.WriteLine(" Both the jobs are same.");
}
else if (jobs[0].Equals(jobs[2]))
{
Console.WriteLine(" Both the jobs are same.");
}
else if (jobs[1].Equals(jobs[2]))
{
Console.WriteLine(" Both the jobs are same.");
}
else
{
Console.WriteLine(" Both the jobs are not same.");
}
Console.WriteLine(" Press any key to continue...");
Console.ReadKey();
}
}
}
3) RushJob (to be completed)
namespace JobDemo
{
class RushJob : Job
{
public const double PREMIUM = 150.00;
//TODO: Constructor with no parameters: public RushJob()
//TODO: update Hour property with new price calculation: price = hours * RATE + PREMIUM;
public override string ToString()
{
//TODO:
}
}
}
Explanation / Answer
Your Program with implementaion. If need any help comment me. Thanks 1) Job.cs namespace JobDemo { class Job { protected double hours; protected double price; public const double RATE = 45.00; public Job(int num, string cust, string desc, double hrs) { this.JobNumber = num; this.Customer = cust; this.Description = desc; hours = hrs; price = hours * RATE; } public int JobNumber { get; set; } public string Customer { get; set; } public string Description { get; set; } public double Hours { get { return hours; } set { hours = value; price = hours * RATE; } } public double Price { get { return price; } } public override string ToString() { return (GetType() + " " + JobNumber + " " + Customer + " " + Description + " " + Hours + " hours @" + RATE.ToString("C") + " per hour. Total price is " + Price.ToString("C")); } public override bool Equals(Object e) { if (this.JobNumber == ((Job)e).JobNumber) return true; else return false; } public override int GetHashCode() { return JobNumber; } } } 2) Program.cs namespace JobDemo { class Program { static void Main(string[] args) { Job[] jobs = new Job[3]; jobs[0] = new Job(111, "John", "Analyst", 12); jobs[1] = new Job(112, "Clary", "Programmer", 14.15); jobs[2] = new Job(113, "Jason", "Developer", 13.15); Console.WriteLine(jobs[0].ToString()); Console.WriteLine(jobs[1].ToString()); Console.WriteLine(jobs[2].ToString()); if (jobs[0].Equals(jobs[1])) { Console.WriteLine(" Both the jobs are same."); } else if (jobs[0].Equals(jobs[2])) { Console.WriteLine(" Both the jobs are same."); } else if (jobs[1].Equals(jobs[2])) { Console.WriteLine(" Both the jobs are same."); } else { Console.WriteLine(" Both the jobs are not same."); } Console.WriteLine(" Press any key to continue..."); Console.ReadKey(); } } } 3) RushJob (to be completed) namespace JobDemo { class RushJob : Job { public const double PREMIUM = 150.00; //TODO: Constructor with no parameters: // parameter of base class should be passed public RushJob(int num, string cust, string desc, double hrs) : base(num,cust,desc,hrs) { } //TODO: update Hour property with new price calculation: price = hours * RATE + PREMIUM; // we can do this work in constructor it self // its also depands upon your logic public void UpdatePrice() { Price = Hours * RATE + PREMIUM; } // To string method public override string ToString() { return (GetType() + " " + JobNumber + " " + Customer + " " + Description + " " + Hours + " hours @" + RATE.ToString("C") + " per hour. Total price is " + Price.ToString("C")); } } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.