Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- 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)
- {
- JobNumber = num;
- Customer = cust;
- Description = desc;
- hours = hrs;
- }
- 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 (e is Job)
- {
- if (((Job)e).JobNumber == JobNumber) //Could also be e as job
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- else
- {
- return false;
- }
- }
- public override int GetHashCode()
- {
- return JobNumber;
- }
- }
- }
- //////////////////////////////
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace JobDemo
- {
- class RushJob : Job
- {
- public const double PREMIUM = 150.00;
- public RushJob() : base() {}
- public double Hours
- {
- get { return hours; }
- set
- {
- hours = value;
- price = hours * RATE + PREMIUM;
- }
- }
- public override string ToString()
- {
- return (GetType() + " " + JobNumber + " " + Customer + " " +
- Description + " " + Hours + " hours @" + RATE.ToString("C") +
- " per hour. " + "Rush job adds " + PREMIUM.ToString("C") + ". Total price is " + Price.ToString("C"));
- }
- }
- }
- /////////////////////////////////
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace JobDemo
- {
- class Program
- {
- static void Main(string[] args)
- {
- Job[] jobs = new Job[3];
- int[] nums = new int[3];
- bool tf = false;
- //TODO: take user input, construct Job or RushJob object, and save it to the Job array declared above.
- foreach (Job job in jobs)
- {
- }
- //TODO: Use the jobs array, display all jobs information
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement