whats wrong im my code

+1 vote
asked Oct 22, 2018 by suhas
import java.util.*;
abstract class Car
{
   int regno;
   Car(int regno)
{
   this.regno=regno;
}
   void fillTank()
   {
     System.out.println("Tank is full");
    }
    abstract void steering(int direction);
    abstract void brakes(int force);
}
class Maurthi extends Car
{
  Maurthi()
  {
   super(2000);
   System.out.println("regno"+regno);
   }
 void steering(int direction)
 {
   if(direction==1)
   {
     System.out.println("LEFT");
   }
   else if(direction==2)
   {
     System.out.println("STRAGHIT");
    }
    else
     {
       System.out.println("RIGHT");
     }
}
void brakes(int force1)
{
  if(force1<=500)
  {
     System.out.println("DRUM BRAKES");
   }
   else
    {
      System.out.println("DISC BRAKES");
     }
}
}
class Santro extends Sai
{
  Santro()
   {
     super(5000);
     System.out.println("regno"+regno);
   }
   void sterring(int direction)
   {
      if(direction==1)
      {
        System.out.println("LEFT");
       }
       else if(direction==2)
       {
         System.out.println("STRAGHIT");
        }
      else
      {
        System.out.println("RIGHT");
    }
}
void brakes(int force)
{
  if(force<=500)
  {
     System.out.println("DRUM BRAKES");
   }
   else
    {
      System.out.println("DISC BRAKES");
     }
}
}
public class Demo2
{
  public static void main(String args[])
  {
   Maruthi M=new Maurthi();
     M.openTank();
     M.sterring();
     M.brakes();
    Santro S=new Santro();
      S.openTank();
      S.sterring();
      S.brakes();
    }
}

1 Answer

+1 vote
answered Apr 9, 2019 by zemiak

there is some typos and missing parameters

correct :your code   ..explanationclass
class Santro extends Car Sai               ..doesn't existSantro
void steering(int direction){ sterring        ..typo at 'terr'Santro
Maurthi M =new Maurthi(); Maruthi M    ..typo at MarDemo2
M.fillTank(); M.openTank();  ..'open' doesn't existDemo2
S.fillTank(); S.openTank();  ..'open' doesn't existDemo2
M.steering(1); M.sterring()   ..typo at 'terr'|no parameterDemo2
S.steering(2)S.sterring()   ..typo at 'terr'|no parameterDemo2
M.brakes(400);  M.brakes();    ..no parameterDemo2
S.brakes(600);  S.brakes();    ..no parameterDemo2


// corrected Demo2
public class Demo2 {
    public static void main(String args[]) {
        Maurthi M =new Maurthi();
         M.fillTank();
         M.steering(1);
         M.brakes(400);
        Santro  S =new Santro();
         S.fillTank();
         S.steering(2);
         S.brakes(600);
    }
}

then Output is:
regno2000
Tank is full
LEFT
DRUM BRAKES
regno5000
Tank is full
STRAGHIT
DISC BRAKES

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...