0

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()
        {
            
        }

    }
        
}
3
Contributors
12
Replies
13
Views
5 Years
Discussion Span
Last Post by cooldj
Featured Replies
  • Check the following code Main[CODE]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:" + … Read More

0

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.

0

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.

0

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

0

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.

0

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. :(

0
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;
        }
    }        
}

Edited by abelLazm: n/a

2

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;
        }
    }
}
Votes + Comments
You are too good for this world.
Nice post
0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.