5
v2
3 String name;
ny String color;
5 int noOfLegs;
io) double weight;
/
fs}
public Animal(String name, String color, int
noOfLegs, double weight) {
9
10 RUST ema
im [Link] = color;
‘V2 [Link] = noOfLegs;
i} Smet eee Lae a1
iv
ae
16
i public void eat() {
as} [Link]("Eating’);
19 ,
20 public void sleep() {
v2 [Link]("Sleeping");
Pee
vee
POM aol eau air Bt
25
26 String breed;
27 int noOfTypes;
28 int noOfColors;
30
ei Horse(String name, String color, int noOfLegs,
double weight, String breed, int noOfTypes, int
noOfColors) {
RY super(name, color, noOfLegs, weight);
KK HUalIom ok -1e ea.
7) SUaTomtel0) BY] 0\- Sea 11eL@) AN 9-H
ie) [Link] = noOfColors;
36 ,ole}
67
iets)
39
70
wat
Tab
t
public void canRun() {
[Link]("Running");
public void canJump() {
[Link]('Jumping’);
}
class ArabianHorse extends Horse {
int speed;
int price;
ArabianHorse(String name, String color, int
noOfLegs, double weight, String breed, int
noOfTypes, int noOfColors, int speed, int price) {
super(name, color, noOfLegs, weight, breed,
noOfTypes, noOfColors);
[Link] = speed;
[Link] = price;
i
public void loyalty() {
[Link]("Loyal");
public void intelligence() {
[Link]("Intelligent’);
}
public static void main(String] args) {
ArabianHorse ah = new ArabianHorse("Horse’,
"Black’, 4, 20.5, "Arabian Horse", 400, 4, 40, 5000);
[Link]([Link]);
[Link]([Link]);
[Link]([Link]);
[Link]([Link]); >
Cuetam out nrintin(ah anand):
{ |} | = | a |< |super(name, color, noOtLegs, weight, breed,
noOfTypes, noOfColors);
tod [Link] = speed;
cm [Link] = price;
boy
}
55 | // Additional Behaviours
56 public void loyalty() {
Ey] [Link]("Loyal");
bets)
59 public void intelligence()
60 [Link](‘Intelligent’);
|
62
63 | public static void main(String[] args) {
64| // creating instance of ArabianHorse
65 ArabianHorse ah = new ArabianHorse("Horse",
"Black", 4, 20.5, "Arabian Horse", 400, 4, 40, 5000);
66 //Accessing properties and behaviours of Arabia
Horse
67| [Link]([Link]);
68 [Link]([Link]);
69} [Link]([Link]);
70, [Link]([Link]);
71 [Link]([Link]);
72 [Link]();
73 | FlamecTala Ui 0H
rE}
75 }[Program finished]]]public class Product{
ASU e MATT baLon
A. String color;
5 double weight;
Y public Product(String name, String color, double
weight) {
i) SMT emo
[Link] = color;
[Link] = weight;
i
public void canBuy() {
[Link]("Buying");
i
public void canSell() {
[Link]("Selling");
i
i
class Bag extends Product {
String brand;
String type;
int typesOfBags;
Bag(String name, String color, double weight,
String brand, String type,int typesOfBags) {
super(name, color, weight);
[Link]=brand;
[Link]=type;
[Link] = typesOfBags;
i
public void canOpen() {
[Link]("Opening’);
public void canClose() { b
ee es fe ee eS (|Ey
Ef
36
et
39
rT)
a
ry)
ov
vy
on
]
rr
rt
50
oy
52
53
55
56
Sv]
58
59
60
61
ys
63
ey
65
Lolo)
vs
BR
public void canOpen() {
[Link]("Opening’);
public void canClose() {
[Link]("Closing");
i
| class HandBag extends Bag {
String material;
int noOfPockets;
Tale lac) 8 8
HandBag(String name, String color, double weight}
String brand, String type,int typesOfBags, String
material, int noOfPockets, int warranty) {
super(name, color, weight, brand, type,
typesOfBags);
Ulomenrel Carel arelc-lat-]
this. noOfPockets=noOfPockets;
[Link]=warranty;
i
public void canCarry() {
[Link]("Carrying");
public void canStyle() {
[Link]("Styling");
yi
public static void main(String[] args) {
HandBag hb= new HandBag("'Bag", "Brown", 1.3}
"Fargo","HandbBag',4, "Leather",3,6);
>
LWT Tene TE mt evateti elds) sms Test-) oo50
roa)
iY
53
or
Ssh)
Sole}
cov
58
59
60
61
ly
63
ry
65
ole}
lov4
68
69
70
71
vA
73
fe
75
76
va
faeiCcate ale Reet int warranty) {
super(name, color, weight, brand, type,
typesOfBags);
[Link]=material;
[Link]=noOfPockets;
ANTEC TUN en LEER
// Additional Behaviours
public void canCarry() {
[Link]("Carrying’);
i
public void canStyle() {
[Link]("Styling’);
H
public static void main(String[] args) {
// creating instance of Hand Bag
HandBag hb= new HandBag("'Bag", "Brown’, 1.3,
"Fargo’,"HandbBag'4, DRTC K SF
//Accessing properties and behaviours of
HandBag
[Link]([Link]);
SV CcUuamere lm eT alt) Rexel (o1 9
[Link]([Link]);
[Link]([Link]);
[Link](hb. material);
[Link]();
[Link]();
[Link]();ereyeg
Toa)
rN
HandbBag
dat
Opening
Buying
Tala eal
dae Pea T8 |NN
PN Ee)
OE)
NN
public class Fruit {
String name;
String color;
Tae ni- (e118
public Fruit(String name, String color, int weight) {
Maite L
[Link] = color;
[Link] = weight;
}
public void canEat() {
[Link]("Eating');
i
public void canCut() {
[Link](Cutting’);
}
i
class Banana extends Fruit {
String size;
String type;
int noOfTypes;
Banana(String name, String color, int weight,
String size, String type, int noOfTypes) {
super(name, color, weight);
[Link] = size;
SA] L-Rem NOH
stam ael0) 8 B91 elO] A 1
i
public void makeShake() {
| ¢ | >} | = |e [| «|TEMALAR -) = noOfTypes;
i
public void makeShake() {
[Link]("Banana Shake’);
:
public void canBake() {
SSAC ceaMelel Medea stl dine
Hi
i
class RedBanana extends Banana {
String origin;
Tal aelale LN BY ol
54 RedBanana(String name, String color, int weight,
String size, String type, int noOfTypes, String origin,
int originType) {
super(name, color, weight, size, type,
noOfTypes);
[Link] = origin;
[Link] = originType;
}
55
public void garnish() {
[Link]("Garnishing’);
i
public void sweets() {
[Link]("Making Sweets’);
}
69 public static void main(String[] args) {
RedBanana rb = new RedBanana("Bal
ee Se |Hulcmelile i eemels(¢) [0H
vi [Link] = originType;
ici
60| // Additional Behaviours
61 public void garnish() {
ya [Link]("Garnishing");
63| }
64
65 public void sweets() {
ole) [Link]("Making Sweets");
Ar
(ets]
69 public static void main(String[] args) {
70 // creating instance of RedBanana
val RedBanana rb = new RedBanana("Banana’,
"Red", 2, "Medium sized", "Red Banana’, 5, "Red
Dacca Banana’, 2);
7 // Accessing properties and behaviours of
RedBanana
73 | [Link]([Link]);
re) [Link]([Link]);
75 [Link]([Link]);
76 [Link]([Link]);
77 [Link]([Link]);
78 [Link]();
79 [Link]();
80 ROH
ro
cy€ TAB
Banana
Red
NtoR AUT es 420]
Red Banana
Red Dacca Banana
these
Seemed
Making Sweets
[Program finished]]1
v2
}
rm
i}
6
vi
cs)
9
i}
a
nl
vd
aK}
ir
ry
16
v7
oF}
19
public class Furniture {
String name;
String color;
double length;
double width;
double weight;
/ Constructc
public Furniture(String name, String color, double
length, double width, double weight) {
taToM Are Tan Mom tral
[Link] = color;
[Link] = length;
SATU ESR WU (elt
[Link] = weight;
i
ehaviours
public void canUse() {
[Link]("Using’);
Y
public void decorate() {
[Link]("Decoration’);
i
i
class Chair extends Furniture {
ional Properties
String type;
boolean hands;
boolean wheels;
int noOfLegs;
int noOfTypes;
// Constructe
Chair(String name, String color, double I
double width, double weight, String type,
hands, boolean wheels, int noOfLegs, intCe TATU) name, String color, double length,
e weight, String type, b
wheels, int noOfLegs, in
noOfTypes) {
38 r(name, color, length, width, weight);
39 1 re eld
40 Lar TaNs Sawa ° oH
cy wheels = wheels;
LY ioOfLegs = noOfLegs;
[Link] = noOfTypes;
iy oid cansit() {
48 [Link]("Sitting");
i
public void canStand() {
by [Link]("Standing");
i
SETS eur)
| Properties
vA String brand;
ete
3 Chair {
xtend
Constructor
61 TaskChair(String name, String color, double
Cale amo LeLel eR Tred UmeLeeL ol RWC 1e i) RS] UL Ae RS 8
boolean hands, n wheels, int noOfLegs, int
| noOfTypes, String brand, int price) {
super(name, color, length, width, weight, type,
hands, wheels, noOfLegs, noOfTypes);
brand = brand;
price = price;
62
ioe}
ov
icf]
lax ours
Te canAdjust() { ri)
69 [Link]("Adjusting Heig————
i
// Additional Behaviours
public void canAdjust() {
[Link]("Adjusting Height");
public void canRotate() {
[Link]("Rotating');
i
public static void main(String] args) {
// Creating instance of TaskChair
TaskChair tc = new TaskChair("Chair", "Black",
10.5, 5.5, 6.5, "Task Chair’, true, true, 5, 4, "Ayra’,
0)
80
// Accessing properties and behaviours of Task
(Carlie
[Link]([Link]);
[Link]([Link]);
[Link]([Link]);
[Link]([Link]);
[Link]([Link]);
[Link]();
[Link]();oS TAB
Garba
Sa-Tol a
true
Task Chair
Nar)
Say o4
Rotating
[Program finished]1 | public class Cloth {
v7 ame) a os
Ke} String name;
4| String color;
5 String material;
6
vi
ts}
// Constructor
public Cloth(String name, String color, String
arcuate) Re
Ce) [Link] = name;
10 [Link] = color;
1 [Link]=material;
Va
aie}
cy // Behaviours
15| public void canCut() {
iT) [Link]("Cutting");
var
a)
19 public void canStitch() {
20 [Link]("Stitching’);
ya |
yap
23
24 | class Pant extends Cloth {
25 // Additional Properties
26 String brand;
27 int noOfPockets;
28 int size;
ie) // Constructor
31 Pant(String name, String color,String material,
String brand,int noOfPockets, int size) {
CY. super(name, color, material);
33 [Link]=brand;
34 [Link]=noOfPockets;
35 [Link]=size;
|i
// Additional Behaviours
public void durability(){
[Link]("Durable’);
i
public void comfort() {
[Link]("Comfortable’);
H
i
public static void main(String[] args) {
// Creating instance of Jeans
Jeans jeans= new Jeans("Pant’, "Black",
"Cotton","LEE",4,38,10,"Wide",5499);
// Accessing properties and behaviours of
Jeans
[Link]([Link]);
[Link]([Link]);
[Link]([Link]);
[Link]([Link]);
[Link](jeans. price);
[Link]();
[Link]();
[Link]();lane
Black
Wide
ers}
5499
Cutting
Washing
DUT at] oR
ogee Pete) |