object orientation: code that understands which line I want to show? PHP


I am new here, but I had already done other research here, reading the existing topics. I am studying PHP The teacher asked for a code to pass the car. IMPORTANT Please do not answer this exercise, I want explanations. If I need to learn something new to do what I want, tell me what it is.

In "return", I start by saying that the car is stopped, already on line 55 I say it changes to first.
Consequently, on line 56 it accelerates and rises up to 20 km / h. To go beyond that speed, you need to shift into second gear.
So on line 57, although it is the same command as on line 55, I mean it should go to second gear. As expected, this does not happen.

DOUBT

It is possible, in php, to make understand the code, that in line 55 I want
let him take into account what I wrote on line 19 (up there), and in
line 57, note what I wrote 25? Because when
I create the object of the car. I can't "configure" the gear since it doesn't have a method,
and even if you had the code, always consider the last line, i.e. even
I had two lines to access the march method and on the first line
If I "set" gear 1 and on the second line gear 2, the code would put gear 2 on both lines 57 and 55.

Thanks for your attention!

dono=$dono;
        $this->Vatual=0;
    }

    public function setAcelerar(){
        if($this->Vatual==0){
//linha 19          $this->marcha=1;
        }
        $this->Vatual+=20;       
// Marcha 1 engatada. O carro acelera até 20km/h. O "if" abaixo confere se é isso mesmo.

        if($this->Vatual <= 20){
// linha 25          $this->marcha=2;
        }
        $this->Vatual+=40;
// Marcha 2 engatada. O carro acelera até 40km/h. O "if" abaixo confere se é isso mesmo.

        if($this->Vatual <= 40){
            $this->marcha=3;
        }
        $this->Vatual+=60;
// Marcha 3 engatada. O carro acelera até 60km/h. O "if" abaixo confere se é isso mesmo.

        if($this->Vatual <= 60){
            $this->marcha=4;
        }
       $this->Vatual+=75;
// Marcha 4 engatada. O carro acelera até 75km/h. O "if" abaixo confere se é isso mesmo.

        if($this->Vatual <= 75){
            $this->marcha=5;
        }
        $this->Vatual+=25;
// Marcha 5 engatada. O carro acelera até 220km/h. 
       }

        public function setCombustivel($combustivel){
             $this->combustivel=$combustivel;
        }

        public function getInfo(){
            return " 

carro parado !
//linha 55 engata marcha {$this->marcha}
//linha 56 Carro acelera até {$this->Vatual}
//linha 57 então passa para marcha {$this->marcha} e
Acelera até {$this->Vatual}

" ; } } $Carro = new Carro ('SickAndTired'); echo $Carro->getInfo(); ?> ```