Click here to Skip to main content
15,891,513 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# XmlReader Pin
Ennis Ray Lynch, Jr.27-Mar-07 8:48
Ennis Ray Lynch, Jr.27-Mar-07 8:48 
AnswerRe: C# XmlReader Pin
Austin Harris27-Mar-07 9:08
Austin Harris27-Mar-07 9:08 
AnswerRe: C# XmlReader Pin
BoneSoft27-Mar-07 9:44
BoneSoft27-Mar-07 9:44 
QuestionHow to sort ListView items of some column. Pin
Saikek27-Mar-07 8:11
Saikek27-Mar-07 8:11 
AnswerRe: How to sort ListView items of some column. Pin
BoneSoft27-Mar-07 9:52
BoneSoft27-Mar-07 9:52 
AnswerRe: How to sort ListView items of some column. Pin
rahvyn627-Mar-07 9:54
rahvyn627-Mar-07 9:54 
QuestionSource ThreadException Pin
AAKAra27-Mar-07 8:06
AAKAra27-Mar-07 8:06 
Question2 Questions Pin
JMOdom27-Mar-07 7:35
JMOdom27-Mar-07 7:35 
I trying to learn C# and I've got two questions for someone. Confused | :confused:

1) In my property statements when I have a speed property I keep getting told The type 'CarProjects.Car' already contains a definition for 'Speed'. I didn't think that I really had a definition for Speed in there. Hopefully someone can explain what I may be doing wrong. Confused | :confused:

2) In the Decelerate() method I need to take the final speed from accelerate and use it to set up for my braking speed. The way it is now I'm fine with the accelerate which gives me a 25 MPH boost over the initial speed. I can also get a -25 MPH shown in the decelerate. I had originally thought that I could make a method that would add the "brake" speed to the "speed" method. I simpply can't get it to work. Can someone give me a clue as to how I can make this work? Sigh | :sigh:

Any help will be appreciated.Smile | :)

public class Car     <br />
	   private int speed = 0;<br />
        private int brake = 0;<br />
		 private int Accel = 0;<br />
        private int Speed = 0;<br />
		//Property statment<br />
		<br />
        public int Speed<br />
        {<br />
            get<br />
            {<br />
                return speed;<br />
            }<br />
            set<br />
            {<br />
                speed = value;<br />
            }<br />
        }<br />
		public int Brake<br />
        {<br />
            get<br />
            {<br />
                return brake;<br />
            }<br />
            set<br />
            {<br />
                brake = value;<br />
            }<br />
        }<br />
		<br />
		 public Car(int speed, int brake, int accelerate)<br />
        {<br />
            accelerate = Accel;<br />
            brake = Brake;<br />
            speed = Speed;<br />
        }<br />
		<br />
		public static int Accelerate() <br />
        {<br />
            int speed = 0;<br />
            int counter = 1;<br />
            Console.WriteLine();<br />
            Console.WriteLine("Type in the initial speed of car.");<br />
            string inputNumbers = Console.ReadLine();<br />
            speed = int.Parse(inputNumbers);<br />
            <br />
            while (counter < 6)<br />
            {<br />
                speed += 5;<br />
                counter++;<br />
              }<br />
              Console.WriteLine();<br />
              Console.WriteLine("Top speed of the car is: {0}", speed);<br />
              return speed;<br />
          }<br />
	}<br />
            public static int Decelerate()<br />
          {<br />
            int brake = 0;<br />
            int counter = 1;<br />
            while (counter < 6)<br />
            {<br />
				brake += - 5;<br />
                counter++;<br />
            }<br />
            Console.WriteLine();<br />
            Console.WriteLine("Speed after braking is: {0} ", brake);<br />
            return brake;<br />
	}<br />
        }

AnswerRe: 2 Questions Pin
led mike27-Mar-07 7:48
led mike27-Mar-07 7:48 
AnswerRe: 2 Questions Pin
Leslie Sanford27-Mar-07 7:55
Leslie Sanford27-Mar-07 7:55 
GeneralRe: 2 Questions Pin
JMOdom27-Mar-07 11:02
JMOdom27-Mar-07 11:02 
GeneralRe: 2 Questions Pin
Leslie Sanford27-Mar-07 11:14
Leslie Sanford27-Mar-07 11:14 
AnswerRe: 2 Questions Pin
Rudolf Jan28-Mar-07 0:10
Rudolf Jan28-Mar-07 0:10 
GeneralRe: 2 Questions Pin
JMOdom28-Mar-07 13:27
JMOdom28-Mar-07 13:27 
QuestionSystem.Diagnostics.Process.StartInfo Username= "default user"? Pin
Austin Harris27-Mar-07 6:59
Austin Harris27-Mar-07 6:59 
AnswerRe: System.Diagnostics.Process.StartInfo Username= "default user"? Pin
kubben27-Mar-07 7:57
kubben27-Mar-07 7:57 
GeneralRe: System.Diagnostics.Process.StartInfo Username= "default user"? Pin
Austin Harris27-Mar-07 8:48
Austin Harris27-Mar-07 8:48 
GeneralRe: System.Diagnostics.Process.StartInfo Username= "default user"? Pin
kubben27-Mar-07 9:19
kubben27-Mar-07 9:19 
QuestionAuto generated number Pin
Neo_Shehpar27-Mar-07 6:44
Neo_Shehpar27-Mar-07 6:44 
AnswerRe: Auto generated number Pin
Leslie Sanford27-Mar-07 7:23
Leslie Sanford27-Mar-07 7:23 
GeneralRe: Auto generated number Pin
Christian Graus27-Mar-07 7:26
protectorChristian Graus27-Mar-07 7:26 
AnswerRe: Auto generated number Pin
Christian Graus27-Mar-07 7:24
protectorChristian Graus27-Mar-07 7:24 
AnswerRe: Auto generated number Pin
Austin Harris27-Mar-07 7:27
Austin Harris27-Mar-07 7:27 
AnswerRe: Auto generated number Pin
kubben27-Mar-07 7:42
kubben27-Mar-07 7:42 
GeneralRe: Auto generated number Pin
Austin Harris27-Mar-07 8:52
Austin Harris27-Mar-07 8:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.