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

C#

 
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 
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 
Ok, the main thing is that you need to maintain the state of the car during and between calls to Accelerate and Decelerate. In other words, you need to keep track of the speed of the car during and between calls to those methods. You can do this with a speed field. This is a trivial example, but it should show you in principle what I'm talking about:

using System;
 
namespace Demo
{
    public class Counter
    {
        private int count;
 
        public Counter(int initialCount)
        {
            count = initialCount;
        }
 
        public void Increment()
        {
            count++;
        }
 
        public void Decrement()
        {
            count--;
        }
 
        public int Count
        {
            get
            {
                return count;
            }
        }
    }
}


To use this object, we could do this:

Counter c = new Counter(40);
 
c.Increment();
c.Increment();
c.Decrement();
 
// etc...


Now, hopefully this will get you started. In place of the Increment method, you will use the Accelerate method. And instead of the Decrement method, you will use the Decelerate method. And instead of the Count property, you will use the Speed property, and so on. You will then need to put in extra logic to handle your requirements regarding maximum speed allowed and so forth.

The key here is that encapsulated in the Counter object is the state of the object. This state is maintained between calls to the methods. I'm not sure, but I think this may have been where you were having trouble with your code. I'd need to take a second look.
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 
GeneralRe: Auto generated number Pin
kubben27-Mar-07 9:13
kubben27-Mar-07 9:13 
AnswerRe: Auto generated number Pin
Neo_Shehpar29-Mar-07 11:02
Neo_Shehpar29-Mar-07 11:02 
Questionhow to get logged in user name Pin
Nkuttynasi27-Mar-07 6:40
Nkuttynasi27-Mar-07 6:40 
AnswerRe: how to get logged in user name Pin
Not Active27-Mar-07 6:46
mentorNot Active27-Mar-07 6:46 

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.