Start Main( ) or btnRun_Click( )
Create a RaceCar object
Set the car name to “Fast One”
Set the x coordinate to 200
Set the y coordinate to 100
Call the car’s Move( ) method and show the resulting message
Display a blank line to separate the two object results

Create an Employee object
Set the employee’s first name to “Joe” and last name to “Student”
Set the phone to “555-1111”
Set the annual salary to 74395.11
Call the employee’s CalculatePay( ) method and display the weekly pay amount
Stop

Add the following code to the Move( ) method of the RaceCar class:
x = x + 5; // same as x += 5;
return "Current Position: " + x;
Add the following code to the CalculatePay( ) method of the Employee class:
return annualSalary / 52.0;

I need help with program. this is what I have so far:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Week2Lab
{
    class Program
    {
        static void Main(string[] args)
        {
            
            
            
        }
        
        

    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Week2Lab
{
    public class Employee
    {
        private string firstName;
        private string lastName;
        private char phone;
        private double annualSalary;

        public Employee()
        {
            string firstName = "Joe";
            string lastName = "Student";
            char phone = "555-1111";
            double annualSalary = 74395.11;
        }

        public string FirstName
        {
            get { return firstName; }
            set { lastName = value; }
        }

        public string LastName
        {
            get { return lastName; }
            set { lastName = value; }
        }

        public char Phone
        {

            get { return phone; }

        }
           
        public double calculatePay
        {
            get
            {
                return annualSalary / 52.0;
            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Week2Lab
{
    public class RaceCar
    {
        private string name;
        private int x_coordinate;
        private int y_coordinate;

        public RaceCar()
        {
            //Set the car name to “Fast One”
            name = "Fast One";
            //Set the x coordinate to 200
            x_coordinate = 200;
            //Set the y coordinate to 100
            y_coordinate = 100;
       
        }

        public void Move()
        {
            Console.ReadLine();                        
        }

        public string CurrentPosition()
        {
            
        }

    }
        
}

what help u need? what is the error?

what help u need? what is the error?

I am sorry was my first post. But all I want to know if my code looks legal and I am on right direction. And just a quick start onto next step after what i have so far. I am just going blank on this thought get help.

OK...let it be checked don't rush for the answer :)

Don't panic!
You are on a right track. Read your assignment carefully.
Example: Create a RaceCar object on line 12 of your code write: RaceCar myCar = new RaceCar();
You should remove line 89 etc. out of the constructor and use them in Main. Not every racecar will be named "Fast Car" etc.

Can someone guide to point how i can have output please!

Thanks for the link. I was more confused of output regarding this particular prgm if anyone could help. Please I have this lab due tmrw and I am not trying to ask for free one here.. just when I am confused after trying a lot I came to this site. Please need help soon to finish this prgm. Thanks in advance.

what is ur question?

to be honest question is how do finish this prgm..i mean this is first time he made us create classes differently and i am just having hard time understanding how to write output. It might be really basic for lot of you but I am trying to be there just not working. I just need to finish this prgm. :(

using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Week2Lab
{
    class Program
    {
        static void Main(string[] args)
        {            
            RaceCar object1=new RaceCar();
           String current_position=object1. CurrentPosition();
             Employee object2=new  Employee();
           double salary=object2.calculatePay();
          Console.WriteLine(current_position);
         Console.WriteLine();
         Console.WriteLine();
         Console.WriteLine(salary+"");
        }
}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Week2Lab
{
    public class Employee
    {
        private string firstName;
        private string lastName;
        private char phone;
        private double annualSalary;

        public Employee()
        {
            string firstName = "Joe";
            string lastName = "Student";
            char phone = "555-1111";
            double annualSalary = 74395.11;
        }

        public string FirstName
        {
            get { return firstName; }
            set { lastName = value; }
        }

        public string LastName
        {
            get { return lastName; }
            set { lastName = value; }
        }

        public char Phone
        {
            get { return phone; }
        }
           
        public double calculatePay
        {
            get
            {
                return annualSalary / 52.0;
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Week2Lab
{
    public class RaceCar
    {
        private string name;
        private int x_coordinate;
        private int y_coordinate;

        public RaceCar()
        {
            //Set the car name to “Fast One”
            name = "Fast One";
            //Set the x coordinate to 200
            x_coordinate = 200;
            //Set the y coordinate to 100
            y_coordinate = 100;
       
        }

        public String Move()
        {
           // Console.ReadLine();                        
            x_coordinate= x_coordinate + 5; // same as x += 5;
           return "Current Position: " +  x_coordinate+"\n"+ y_coordinate;
        }

        public string CurrentPosition()
        {
          String current=Move();
           return current;
        }
    }        
}

Check the following code Main

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Week2Lab
{
    class Program
    {
        static void Main(string[] args)
        {
            Employee object1 = new Employee();
            object1.FirstName = "Joe";
            object1.LastName = "Student";
            object1.Phone = "555-1111";
            Console.WriteLine("Name:" + object1.FirstName + " " + object1.LastName);
            Console.WriteLine("PhoneNumber:" + object1.Phone);
            Console.WriteLine("Salary:" + object1.calculatePay(74395.11));
            Console.WriteLine("\n\n");
            RaceCar object2 = new RaceCar();
            Console.WriteLine(object2.CurrentPosition());
            Console.ReadLine();
        }
    }
}

Employee

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Week2Lab
{
    class Employee
    {
        private string firstName;
        private string lastName;
        private String phone;
       // private double annualSalary;

        public Employee()
        {
           
        }

        public string FirstName
        {
            get { return firstName; }
            set { firstName = value; }
        }

        public string LastName
        {
            get { return lastName; }
            set { lastName = value; }
        }

        public String Phone
        {
            get { return phone; }
            set { phone = value; }
        }
      


        public double calculatePay (double annualSalary)
        {
              return annualSalary / 52.0;
        }
    }
}

RaceCar

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Week2Lab
{
    class RaceCar
    {
        private string name;
        private int x_coordinate;
        private int y_coordinate;

        public RaceCar()
        {
            //Set the car name to “Fast One”
            name = "Fast One";
            //Set the x coordinate to 200
            x_coordinate = 200;
            //Set the y coordinate to 100
            y_coordinate = 100;

        }

        public String Move()
        {
            // Console.ReadLine();                        
            x_coordinate = x_coordinate + 5; // same as x += 5;
            return "Current Position: " + x_coordinate + "\n\t\t  " + y_coordinate;
        }

        public string CurrentPosition()
        {
            String current = Move();
            return current;
        }
    }
}
commented: Nice post +3
commented: You are too good for this world. +14

Thank you guys for helping me out! Special thanks to abelLazm. Much appreciate.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.