Home / Expert Answers / Computer Science / create-an-application-in-c-named-jobdemo-that-declares-and-uses-job-objects-the-job-class-holds-jo-pa995

(Solved): Create an application in C# named JobDemo that declares and uses Job objects. The Job class holds jo ...



Create an application in C# named JobDemo that declares and uses Job objects. The Job class holds job information for a home repair service. The class has five properties that include:

  • JobNumber - The job number
  • Customer - The customer name
  • Description - The job description
  • Hours - The estimated hours
  • price - The price for the job

Create a constructor that requires parameters for all the data except price. Include auto-implemented properties for the job number, customer name, and job description, but not for hours or price; the price field value is calculated as estimated hours times $45.00 ($45.00 / hour) whenever the hours value is set.

Also create the following methods for theJob class:

  • An Equals() method that determines two Jobs are equal if they have the same job number
  • A GetHashCode() method that returns the job number
  • A ToString() method that returns a string containing all job information in the following format:
    Job 111 Smith exterior paint 20 hours @$45.00 per hour. Total price is $900.00 

The JobDemo application declares a few Job objects, sets their values, and demonstrates that all the methods work as expected.

In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfo method. In order to do this, include the statement using System.Globalization; at the top of your program and format the output statements as follows: WriteLine("This is an example: {0}", value.ToString("C", CultureInfo.GetCultureInfo("en-US")));

Skip Navigation

Tasks

0.00 out of 10.00

Equals() returns the correct values

0 out of 2 checks passed. Review the results below for more details.

Checks

Unit TestIncomplete

The Job class determines if two Job objects are equal

Build Status

Build Failed

Build Output

Compilation failed: 2 error(s), 1 warnings

NtTest82a563e5.cs(5,1): warning CS0105: The using directive for `System' appeared previously in this namespace
NtTest82a563e5.cs(11,9): error CS0246: The type or namespace name `Job' could not be found. Are you missing `JobDemo' using directive?
NtTest82a563e5.cs(12,22): error CS0841: A local variable `job' cannot be used before it is declared

Test Contents

[TestFixture]
public class TestJobEqualsMethod {
    [Test]
    public void FirstJobEqualsMethodTest() {
        Job job = new Job(111, "Smith", "exterior paint", 20);
       Assert.IsTrue(job.Equals(job));
    }
}

Unit TestIncomplete

The Job class determines if two Job objects are not equal

Build Status

Build Failed

Build Output

Compilation failed: 3 error(s), 1 warnings

NtTestb9cad13c.cs(5,1): warning CS0105: The using directive for `System' appeared previously in this namespace
NtTestb9cad13c.cs(11,9): error CS0246: The type or namespace name `Job' could not be found. Are you missing `JobDemo' using directive?
NtTestb9cad13c.cs(12,9): error CS0246: The type or namespace name `Job' could not be found. Are you missing `JobDemo' using directive?
NtTestb9cad13c.cs(13,24): error CS0841: A local variable `job1' cannot be used before it is declared

Test Contents

[TestFixture]
public class TestJobEqualsMethod {
    [Test]
    public void SecondJobEqualsMethodTest() {
        Job job1 = new Job(111, "Smith", "exterior paint", 20);
        Job job2 = new Job(222, "Vega", "gutter clean", 4);
        Assert.IsFalse(job1.Equals(job2));
    }
}

0.00 out of 10.00

GetHashCode() returns the correct values

The GetHashCode() method did not return the expected job number.

Checks

Unit TestIncomplete

The Job class GetHashCode() method returns the proper job number

Build Status

Build Failed

Build Output

Compilation failed: 4 error(s), 1 warnings

NtTesta2c9d287.cs(5,1): warning CS0105: The using directive for `System' appeared previously in this namespace
NtTesta2c9d287.cs(10,8): error CS0246: The type or namespace name `Job' could not be found. Are you missing `JobDemo' using directive?
NtTesta2c9d287.cs(12,24): error CS0841: A local variable `job' cannot be used before it is declared
NtTesta2c9d287.cs(16,11): error CS0246: The type or namespace name `Job' could not be found. Are you missing `JobDemo' using directive?
NtTesta2c9d287.cs(18,29): error CS0841: A local variable `job' cannot be used before it is declared

Test Contents

[TestFixture]
public class TestJobGetHashCodeMethod {
    [Test]
    public void FirstGetHashCodeTest() {
       Job job = new Job(111, "Smith", "exterior paint", 20);
       var comVal = 111;
       Assert.AreEqual(job.GetHashCode(), comVal);
    }
    [Test]
     public void SecondGetHashCodeTest() {
          Job job = new Job(111, "Smith", "exterior paint", 20);
         var comVal = 222;
         Assert.AreNotEqual(job.GetHashCode(), comVal);
    }
}

0.00 out of 10.00

ToString() returns the correct values

The ToString() method did not return the job object's information in the correct format. Review the example provided in the instructions.

Checks

Unit TestIncomplete

Job class ToString() method tests

Build Status

Build Failed

Build Output

Compilation failed: 4 error(s), 1 warnings

NtTest4dc5bbc5.cs(5,1): warning CS0105: The using directive for `System' appeared previously in this namespace
NtTest4dc5bbc5.cs(12,10): error CS0246: The type or namespace name `Job' could not be found. Are you missing `JobDemo' using directive?
NtTest4dc5bbc5.cs(13,23): error CS0841: A local variable `job' cannot be used before it is declared
NtTest4dc5bbc5.cs(21,10): error CS0246: The type or namespace name `Job' could not be found. Are you missing `JobDemo' using directive?
NtTest4dc5bbc5.cs(22,23): error CS0841: A local variable `job' cannot be used before it is declared

Test Contents

[TestFixture]
public class TestJobToStringMethod {
    [Test]
    public void FirstToStringTest() {

Programming Exercise 10-3A
         Job job = new Job(111, "Smith", "exterior paint", 20);
         string res = job.ToString();
         double price = 45.00;
         double total = 900;
         string comVal = "Job 111 Smith exterior paint 20 hours @" + price.ToString("C",CultureInfo.GetCultureInfo("en-US")) + " per hour. Total price is " + total.ToString("C", CultureInfo.GetCultureInfo("en-US")) ;
         Assert.AreEqual(comVal, res.Trim());
    }
    [Test]
    public void SecondToStringTest() {
         Job job = new Job(222, "Vega", "gutter clean", 4);
         string res = job.ToString();
         double price = 45.00;
        double total = 180;
         string comVal = "Job 222 Vega gutter clean 4 hours @" + price.ToString("C", CultureInfo.GetCultureInfo("en-US")) + " per hour. Total price is " + total.ToString("C", CultureInfo.GetCultureInfo("en-US")) ;
        Assert.AreEqual(comVal, res.Trim());
    }
}

 

Programming Exercise 10-3A


We have an Answer from Expert

View Expert Answer

Expert Answer


ANSWER : Below find the Solution: using System; public class Job{ private int jobNumber; private string jobName; private string jobDescription; private int hours; public double price; public Job(int number,string name,string description,int hrs){ job
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe