class player
{
String name;
int age;
player(String n,int a)
{ name=n; age=a; }
void show()
{
System.out.println("\n");
System.out.println("Player name : "+name);
System.out.println("Age : "+age);
}
}
class criket_player extends player
{
String type;
criket_player(String n,String t,int a)
{
super(n,a);
type=t;
}
public void show()
{
super.show();
System.out.println("Player type : "+type);
}
}
class football_player extends player
{
String type;
football_player(String n,String t,int a)
{
super(n,a);
type=t;
}
public void show()
{
super.show();
System.out.println("Player type : "+type);
}
}
class hockey_player extends player
{
String type;
hockey_player(String n,String t,int a)
{
super(n,a);
type=t;
}
public void show()
{
super.show();
System.out.println("Player type : "+type);
}
}
//--------- main -----------
class s04_02
{
public static void main(String args[])
{
criket_player c=new criket_player("Ameer","criket",25);
football_player f=new football_player("arun","foot ball",25);
hockey_player h=new hockey_player("Ram","hockey",25);
c.show();
f.show();
h.show();
}
}
{
String name;
int age;
player(String n,int a)
{ name=n; age=a; }
void show()
{
System.out.println("\n");
System.out.println("Player name : "+name);
System.out.println("Age : "+age);
}
}
class criket_player extends player
{
String type;
criket_player(String n,String t,int a)
{
super(n,a);
type=t;
}
public void show()
{
super.show();
System.out.println("Player type : "+type);
}
}
class football_player extends player
{
String type;
football_player(String n,String t,int a)
{
super(n,a);
type=t;
}
public void show()
{
super.show();
System.out.println("Player type : "+type);
}
}
class hockey_player extends player
{
String type;
hockey_player(String n,String t,int a)
{
super(n,a);
type=t;
}
public void show()
{
super.show();
System.out.println("Player type : "+type);
}
}
//--------- main -----------
class s04_02
{
public static void main(String args[])
{
criket_player c=new criket_player("Ameer","criket",25);
football_player f=new football_player("arun","foot ball",25);
hockey_player h=new hockey_player("Ram","hockey",25);
c.show();
f.show();
h.show();
}
}
Very helpful. It helps a lot to me.
ReplyDeletethanks
ReplyDeletegood job
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteSimply excellent. very good IGNOU students
ReplyDeleteThanks
ReplyDeletepackage programe01;
ReplyDeleteimport java.util.*;
class player
{
String name;
int age;
String type;
void player(String n,int a,String t)
{
this. name=n;
this.age=a;
this.type=t;
}
}
////
class cricket_player extends player
{
void show (String n,int a,String t)
{
System.out.println("---------------------------");
System.out.println("Player Name : "+n);
System.out.println("Player Age : "+a);
System.out.println("Player type : "+t);
}
}
////
class football_player extends cricket_player
{
void show (String n,int a,String t)
{
System.out.println("---------------------------");
System.out.println("Player Name : "+n);
System.out.println("Player Age : "+a);
System.out.println("Player type : "+t);
}
}
/////
class hockey_player extends football_player
{
void show(String n,int a,String t)
{
System.out.println("---------------------------");
System.out.println("Player Name : "+n);
System.out.println("Player Age : "+a);
System.out.println("Player type : "+t);
System.out.println("---------------------------");
}
}
////
class playerinfo
{
public static void main(String[] args)
{
cricket_player c=new cricket_player();
c.show("MS Dhoni",39,"Cricket-Wicket-Keeper");
football_player f=new football_player();
f.show("Sunil Chettri",31,"Football-Strikcer");
hockey_player h=new hockey_player();
h.show("Rani Rampal",27,"Hockey-Forward");
}
}