{\rtf1\ansi\ansicpg874\deff0\deflang1054{\fonttbl{\f0\froman\fprq2\fcharset222 Angsana New;}{\f1\froman\fprq2\fcharset0 Angsana New;}{\f2\fmodern\fprq1\fcharset0 Courier New;}{\f3\fswiss\fcharset0 Arial;}}
{\colortbl ;\red0\green0\blue0;\red102\green102\blue102;\red68\green68\blue68;}
{\*\generator Msftedit 5.41.15.1515;}\viewkind4\uc1\pard\cf1\b\f0\fs32\'a8\'d2\'a1\'e2\'bb\'c3\'e1\'a1\'c3\'c1\'a2\'e9\'d2\'a7\'c5\'e8\'d2\'a7 \'a8\'a7\'e1\'a1\'e9\'e4\'a2\'e3\'cb\'e9\'b6\'d9\'a1\'b5\'e9\'cd\'a7\lang1033\b0\f1\par
\pard\sl360\slmult0\tx916\tx1832\tx2748\tx3664\tx4580\tx5496\tx6412\tx7328\tx8244\tx9160\tx10076\tx10992\tx11908\tx12824\tx13740\tx14656\cf0\f2\fs20 \cf2\lang2057\b public class Bicycle \{\par
\tab\par
// the Bicycle class has three \i fields\i0\par
public int cadence;\par
public int gear;\par
public int speed;\par
\tab\par
// the Bicycle class has one \i constructor\i0\par
public Bicycle(int startCadence, int startSpeed, int startGear) \{\par
gear = startGear;\par
cadence = startCadence;\par
speed = startSpeed;\par
\}\par
// the Bicycle class has four \i methods\i0\par
public void setCadence(int newValue) \{\par
cadence = newValue;\par
\}\par
\tab\par
public void setGear(int newValue) \{\par
gear = newValue;\par
\}\par
\tab\par
public void applyBrake(int decrement) \{\par
speed -= decrement;\par
\}\par
\tab\par
public void speedUp(int increment) \{\par
speed += increment;\par
\}\par
\tab\par
\}\par
\par
class MountainBike extends Bicycle \{\par
\tab\par
// the MountainBike subclass adds one \i field\i0\par
public int seatHeight;\par
\par
// the MountainBike subclass has one \i constructor\i0\par
public MountainBike(int startHeight, int startCadence, int startSpeed, int startGear) \{\par
super(startCadence, startSpeed, startGear);\par
seatHeight = startHeight;\par
\}\tab\par
\tab\par
// the MountainBike subclass adds one \i method\i0\par
public void setHeight(int newValue) \{\par
seatHeight = newValue;\par
\}\tab\par
\}\par
\par
\pard\brdrl\brdrs\brdrw10\brsp120 \cf3\b0\fs32 public \lang1033 \lang2057 class\lang1033 \lang2057 inheritanceBicycle \{\line public static void main(String args[]) \{\line //create the objects of Bicycle & mountainBike\line Bicycle B = new Bicycle(10,20,30);\line mountainBike m = new mountainBike(1,2,300,4);\line // for Bicycle\line System.out.println("value of speed of bicycle " + B.speed);\line B.speedUp(7); \line System.out.println("value of speed after increase " + B.speed);\line System.out.println("value of speed of mountainbike " + m.speed);\line m.speedUp(7); \line System.out.println("value of speed after increase " + m.speed);\line\}\line\pard\}\cf1\lang1033\par
\cf0\f3\fs20\par
}