Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7525791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:39:01+00:00 2026-05-30T03:39:01+00:00

I am not really sure why but when I put break points in and

  • 0

I am not really sure why but when I put break points in and stepped through my code each of the properties return either a null or 0 when they should be the values I put in the main where I mad the instances of the class.

This is my main

namespace DemoJobs
{
    class Program
    {
        static void Main(string[] args)
        {
            string desc;
            decimal rate, time, total;

            Job job1 = new Job("Pour Driveway", 8m, 50.00m);
            Job job2 = new Job("Instal New Windows", 18m, 120m);
            Job job3 = job1 + job2;

            Console.WriteLine("The {0} job will take {1} hours, costing {2} per hour with a total of {3}", 
                job1.Description, job1.Time, job1.Rate.ToString("C"), job1.Total.ToString("C"));

            Console.WriteLine("The {0} job will take {1} hours, costing {2} per hour with a total of {3}", 
                job2.Description, job2.Time, job2.Rate.ToString("C"),  job2.Total.ToString("C"));

            Console.WriteLine("The {0} job will take {1} hours, costing {2} per hour with a total of {3}", 
                job3.Description, job3.Time, job3.Rate.ToString("C"), job3.Total.ToString("C"));

            Console.ReadLine();
        }
    }
}

This is my class

namespace DemoJobs
{
    public class Job
    {
        // variables
        private string _description;
        private decimal _time, _rate, _total;

        // property for the job description
        public string Description
        {
            get { return _description; }
            set { _description = value; }
        }

        // property for the total job time
        public decimal Time
        {
            get { return _time; }
            set { _time = value; CalcTotal(); }
        }

        // property for the jobs hourly rate
        public decimal Rate
        {
            get { return _rate; }
            set { _rate = value; CalcTotal(); }
        }

        // read-only property for the job total
        public decimal Total
        {
            get { return _total; }
        }

        // method to calculate the total for the job
        public decimal CalcTotal()
        {
            _total = _rate * _time;
            return _total;
        }

        // constructor
        public Job(string description, decimal time, decimal rate)
        {
            Description = _description;

            Time = _time;

            Rate = _rate;
        }

        public static Job operator +(Job job1, Job job2)
        {
            string newDescription = job1.Description + " and " + job2.Description;

            decimal newTime = job1.Time + job2.Time;

            decimal newRate = (job1.Rate + job2.Rate) / 2;

            decimal newTotalFee = newRate * newTime;

            return (new Job(newDescription, newTime, newRate));
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T03:39:02+00:00Added an answer on May 30, 2026 at 3:39 am

    In your constructor you are using wrong variable references:

       public Job(string description, decimal time, decimal rate)
        {
            Description = description;
    
            Time = time;
    
            Rate = rate;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So i'm not really sure why this is happening but I'm running through some
Not really sure what's going on with my code but I'm having trouble removing
I'm not really sure how to title this question but basically I have an
I know this is possible but I'm not really sure where to start. Has
I feel like there's a simple solution to this, but I'm not really sure
I have to be missing something simple, but I'm really not sure what. I
Not sure if I really am on the right forum, but if not, just
I´m not sure if this is really a programming question, but it's related to
I'm sure I am just doing something really dumb and not seeing it but
I know this probably really simple but Im not sure what im doing wrong...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.