Package prac_1;/** * <p>title: Tree Parameters </p> * <p>description: Using inherited classes, Willow is the tree </p> * <p>copyright: Copyright (c) 2014</p> * <p>filename: </p> * @author Wanghaitao * @version 0.1 */class tree{/** *<br> Method description : Tree root *<br> input parameter: *<br> return type: */public void root () {String ssite = "Underground"; String sfunction = "absorbing nutrients"; Print ("Where:" +ssite); Print ("What to Do:" +sfunction); }/** *<br> Method Description: Tree trunk *<br> input parameter: *<br> return type: */public void Bolo () {String ssite = "ground"; String sfunction = "nutrient Delivery"; Print ("Where:" +ssite); Print ("What to Do:" +sfunction); }/** *<br> Method Description: Tree branches *<br> input parameters: *<br> return Type: */public void Branch () {String ssite = "on the trunk"; String sfunction = "Transport of nutrients"; Print ("Where:" +ssite); Print ("What to Do:" +sfunction); }/** *<br> Method Description: Tree leaf *<br> input parameter: *<br> return type: */public void leaf () {String ssite = "treetop"; String sfunction = "photosynthesis"; String Scolor = "green"; Print ("Where:" +ssite); Print ("dryWhat: "+sfunction); Print ("What color:" +scolor); }/** *<br> Method Description: Display information *<br> input parameters: Object Opara information displayed *<br> return type: */public void print (Object Opara) {Sy Stem.out.println (Opara); }/** *<br> Method Description: Main method *<br> input parameter: *<br> return type: */public static void Main (string[] arges) {Tree T = new Tree (); T.print ("Describe a normal tree:"); T.print ("root:"); T.root (); T.print ("trunk:"); T.bolo (); T.print ("branches:"); T.branch (); T.print ("Leaves:"); T.leaf (); }}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package prac_1;/** * <p>title: Willow Parameters </p> * <p>description: Description of willow Parameters </p> * <p>copyright: Copyright (c) 2014</p> * <p>filename: </p> * @author Wanghaitao * @version 0.1 */class tree1 extends tree{/** *<br> method Description: Tree leaf *<br> input parameter: *<br> return type: */public void leaf () { super.leaf (); String Sshape = "Lancet"; Super.print ("Shape:" +sshape); } /** *<br> Method Description: Extension tree flower *<br> input parameter: *<br> return type: */public void Flower () { print ("Willow does not blossom wow"); } /** *<br> Method Description: Main method *<br> input parameter: *<br> return type: * /public static void main (string[] args) { C14/>tree1 o = new Tree1 (); O.print ("Willow Roots:"); O.root (); O.print ("Willow Trunks:"); O.bolo (); O.print ("Willow branches:"); O.branch (); O.print ("Willow Leaves:"); O.leaf (); O.print ("Willow Flower:"); O.flower (); }}
A little bit of Java per day (inheritance action)