A little bit per day Java (inheritance operation)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.