The first question.
Student Class-Constructors
Defines a student class for students, containing class member variables: string name, string sex, int age, and all variables must be private.
Program Design idea: According to the topic defines a student's student class, contains the class member variable: string name, string sex, int age, all the variables must be private (private), the construction method student without parameters, Define the construction method with parameters tostring, output name, age, and gender, and create objects in the main function.
Knowledge points used: Defining classes, constructing methods;
Operation Result:
Code Cloud Address: Https://gitee.com/changchundehui/16012008/blob/master/16012008/16012008/Xuesheng.java
Second question
Define the class, please add the following code to complete the output requirements.
Program Design ideas: Define a fun method with parameters, the return value of the parameter can be used to output a five-digit average.
The knowledge points used: parameter passing value, defining method;
Operation Result:
Code Cloud Address: https://gitee.com/changchundehui/16012008/blob/master/16012008/16012008/Average.java#
Third question
Horizontal Flat Vertical
Procedural blanks. Refine the code below as required by the topic. Please submit the full code. If the height of a block is larger than the width, we say it is upright, otherwise we say it is flat. Read into the height and width of a block of wood. If it is flat, then output a, otherwise output B.
Program Design ideas: Define class board, define constructors, method overloads with different parameter types, use parameter values to see "A", or "B".
Knowledge points Applied: Method overloads, constructors
Operation Result:
Code Cloud Address: https://gitee.com/changchundehui/16012008/blob/master/16012008/16012008/Hengpingshuzhi.java#
Question Fourth
Program change the wrong question
Program Design ideas: Define the L class Animal,dog inheritance Animal, because class Animal in the absence of a method to run, the subclass can not inherit the parent class, so you have to add
The knowledge points applied: inheritance and polymorphism.
Operation Result:
Code Cloud Address: Https://gitee.com/changchundehui/16012008/blob/master/16012008/16012008/Chengxugaicuo.java
| Learning content |
Code (line) |
Blog (word) |
| Class |
30 |
|
| Constructing methods and objects |
50 |
|
| Method overloading |
68 |
|
| Package |
84 |
|
| Subclasses and inheritance |
80 |
|
| The second process of assessment |
100 |
300 |
|
|
|
Classroom Practice Code Cloud Address: https://gitee.com/changchundehui/16012008_/tree/master/16012008_
The second process of assessment