Elon's Toys

in ita •  4 months ago

    using System;

    class RemoteControlCar
    {
    private int meters=0; // default wäre auch 0
    private int percentage=100;

      public RemoteControlCar()
    {
       
    }
     public RemoteControlCar(int meters, int percentage)
    {
        this.meters = meters; 
        this.percentage = percentage;
    }
    public static RemoteControlCar Buy()
    {
       RemoteControlCar car1 = new RemoteControlCar();
       return car1;
    }
    
    public string DistanceDisplay()
    {
        return "Driven " +meters+  " meters";
    }
    
    public string BatteryDisplay()
    {
        if(percentage==0)
        return "Battery empty";
        else return "Battery at " + percentage+ "%";
    }
    
    public void Drive()
    {
      if(percentage!=0)
      {
       percentage -= 1;
       meters+=20; 
      }   
    }
    

    }

      Authors get paid when people like you upvote their post.
      If you enjoyed what you read here, create your account today and start earning FREE VOILK!