/*
Create a class named Vehicle that includes,model(
String) and
registration number(String).
Include get methods for these variables, and a constructor that
requires an arguments (model,registration number).
Create an extended class named Car whose constructor requires a owner's name.
Write a program to demonstrate creating and using an object of each class.
*/
import java.io.*;
class Vehicle
{
String model;
String regno;
Vehicle(String m, String r_no)
{
model = m;
regno = r_no;
}
void get_data()
{
// don't know why he is asking for this when i've constructor
}
void show_vehicle_data()
{
System.out.println("Model: "+model);
}
}
class Car extends Vehicle
{
String owner_name;
Car(String m, String r_no, String o_n)
{
super(m, r_no);
owner_name = o_n;
}
void get_data()
{
// don't know why he is asking for this when i've constructor
}
void show_car_data()
{
System.out.println("Registration No: "+regno);
System.out.println("Owner's Name: "+owner_name);
}
public static void main(String args[]) throws IOException
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String model;
String regi_num;
String own_name;
System.out.println("Enter Model: ");
model = in.readLine();
System.out.println("Enter Registration No: ");
regi_num = in.readLine();
System.out.println("Enter Owner's Name: ");
own_name = in.readLine();
Car C = new Car(model, regi_num, own_name);
C.show_vehicle_data();
C.show_car_data();
}
}
my question is, i don't whats the purpose of using get_data methods while constructor is doing that for me.