Job Desc

 using System;

using System.IO;

using System.Linq;

using System.Collections.Generic;

namespace Lecture62

{

  public class Program

  {

 public static void Main()

 {

   Job job1 = new Job();

   job1.JobDescription = "wash clothes";

   job1.Time_in_hours = 1;

   job1.Per_hour_rate = 5;

   Job job2 = new Job();

   job2.JobDescription = "clean house";

   job2.Time_in_hours = 2.5;

   job2.Per_hour_rate = 15;

   Job job3 = job1 + job2;

   Console.WriteLine("Job Description : " + job1.JobDescription);

   Console.WriteLine("Time spent in hours : " + job1.Time_in_hours);

   Console.WriteLine("Hourly rate : " + job1.Per_hour_rate);

   Console.WriteLine("Total fee : " + job1.Totalfee);

   Console.WriteLine();

   Console.WriteLine("Job Description : " + job2.JobDescription);

   Console.WriteLine("Time spent in hours : " + job2.Time_in_hours);

   Console.WriteLine("Hourly rate : " + job2.Per_hour_rate);

   Console.WriteLine("Total fee : " + job2.Totalfee);

   Console.WriteLine();

   Console.WriteLine("Job Descriptions : " + job3.JobDescription);

   Console.WriteLine("Total time : " + job3.Time_in_hours);

   Console.WriteLine("Average hourly rate : " + job3.Per_hour_rate);

 }

 //Class for Harold Home services

 public class Job

 {

   //Data Fields

   private string jobDescription;

   private double time_in_hours;//to complete the job

   private double per_hour_rate;//charged for the job

   private double totalFee;//for the job

   public Job()

   {

   }

   //GetSet

   public string JobDescription

   {

  get

  {

    return jobDescription;

  }

  set

  {

    this.jobDescription = value;

  }

   }

   public double Time_in_hours

   {

  get

  {

    return time_in_hours;

  }

  set

  {

    this.time_in_hours = value;

    this.totalFee = per_hour_rate * time_in_hours;

  }

   }

   public double Per_hour_rate

   {

  get

  {

    return per_hour_rate;

  }

  set

  {

    this.per_hour_rate = value;

    this.totalFee = per_hour_rate * time_in_hours;

  }

   }

   public double Totalfee

   {

  get

  {

    return totalFee;

  }

   }

   //Operator overload

   public static Job operator +(Job job1, Job job2)

   {

  string newjobDescription = job1.jobDescription + " and " + job2.jobDescription;

  double newtimeinhours = job1.time_in_hours + job2.time_in_hours;

  double newhourlyrate = (job1.per_hour_rate + job2.per_hour_rate) / 2;

  Job newjob = new Job();

  newjob.jobDescription = newjobDescription;

  newjob.time_in_hours = newtimeinhours;

  newjob.per_hour_rate = newhourlyrate;

  return newjob;

   }

 }

  }

}

Comments

Popular Posts