<> Object oriented 3 day

<> First day of submarine game :

* Created 6 Class , establish World Class and test
<> The second day of submarine game :

* to 6 Add constructor to class , And test
<> Submarine game day 3 :

* Design reconnaissance submarine array , Torpedo submarine array , Mine submarine array , Mine array , Deep water bomb array , And test
* Design SeaObject Superclass , Design 6 Class inherits superclass
* to SeaObject Design two construction methods ,6 Each derived class is called separately
<> review :

* Construction method :
* Assign initial values to member variables
* Same name as class , No return value type ( even void none )
* Called automatically when an object is created
* If you don't write your own construction method , The compiler provides a parameterless constructor by default , If you write your own structure , It is no longer provided by default
* Can overload
* this: Refers to the current object , Which object calls the method, it refers to which object
this Usage of :
* this. Member variable name ---- Accessing member variables ( When a member variable has the same name as a local variable , Access member variable must be added this.)
* this. Method name ()-------- Call method ( understand )
* this()------------------ Call construction method ( understand )
* null: Indicates null , No object points to , If the referenced value is null, Then the reference cannot perform any point operations ,
Occurs if the operation NullPointerException Null pointer exception
<> note :

* Reference type array :
* Difference from basic type array :
* You must assign a value to an array element new once
* If you want to access object data, you must dot through array elements Student[] stus = new Student[3]; // establish Student Array object stus[0]
= new Student("zhangsan",25,"LF"); // establish Student object stus[1] = new Student("lisi",26
,"JMS"); stus[2] = new Student("wangwu",24,"SD"); System.out.println(stus[0].
name); // Output No 1 The name of a student stus[1].age = 28; // Amendment No 2 The age of students is 28 stus[2].sayHi();
// The first 3 A student said hello to everyone for(int i=0;i<stus.length;i++){ // Traverse all students System.out.println(stus[i]
.name); // Output the name of each student stus[i].sayHi(); // Every student says hello to everyone }

2. inherit :
- effect : code reuse
- adopt extends To implement inheritance
- Superclass / Parent class : Shared attributes and behaviors
Derived class / Subclass : Unique attributes and behaviors
- Derived classes can access their own , You can also access superclasses , However, superclasses cannot access the of derived classes
- A superclass can have multiple derived classes , A derived class can only have one superclass --------- single inheritance
- Transitive
- java regulations : A superclass must be constructed before a derived class can be constructed
- If the constructor of the superclass is not called in the constructor of the derived class , Default super() Call the parameterless constructor of the superclass
- In the construction method of derived class, if you call the construction method of superclass , It is no longer provided by default
> super() Call superclass constructor , Must be at the second level of the derived class constructor 1 that 's ok

* super: A superclass object that refers to the current object
super Usage of :
* super. Member variable name --------------------- Accessing member variables of a superclass
* super. Method name ()------------------------- Call the method of the superclass -------------- Tomorrow afternoon
* super()----------------------------------- Call the constructor of the superclass //super Presentation of public class
SuperDemo { public static void main(String[] args) { Boo o = new Boo(); } }
class Coo{ Coo(int a){ } } class Doo extends Coo{ Doo(){ super(5); // Call the parameterized construction of the superclass }
/* // The following code is the default : Doo(){ super(); } */ } class Aoo{ Aoo(){ System.out.println(
" Super class construction "); } } class Boo extends Aoo{ Boo(){ //super(); // default , Call the parameterless construction of the superclass System.out
.println(" Derived class construction "); } }
<> Essence note :

*
Reference type array :

* Difference from basic type array :
* You must assign a value to an array element new once
* If you want to access object data, you must dot through array elements
*
inherit :

* effect : code reuse
* adopt extends To implement inheritance
* Superclass / Parent class : Shared attributes and behaviors
Derived class / Subclass : Unique attributes and behaviors
* Derived classes can access their own , You can also access superclasses , However, superclasses cannot access the of derived classes
* A superclass can have multiple derived classes , A derived class can only have one superclass --------- single inheritance
* Transitive
* java regulations : A superclass must be constructed before a derived class can be constructed
* If the constructor of the superclass is not called in the constructor of the derived class , Default super() Call the parameterless constructor of the superclass
* In the construction method of derived class, if you call the construction method of superclass , It is no longer provided by default
super() Call superclass constructor , Must be at the second level of the derived class constructor 1 that 's ok

*
super: A superclass object that refers to the current object
super Usage of :

* super. Member variable name --------------------- Accessing member variables of a superclass
* super. Method name ()------------------------- Call the method of the superclass -------------- Tomorrow afternoon
* super()----------------------------------- Call the constructor of the superclass
<> supplement :

* Tomorrow words :1)up: Up 2)load: load 3)animal: animal 4)tiger: tiger 5)override: rewrite
<> task : Need to upload job ------ stay ooday04 Write in package , Because it will be used tomorrow
1. establish Person class , contain : 1) Member variable :name,age,address 2) Construction method :Person(3 Parameters ){ assignment } 3) method :sayHi(){
output 3 Data } 2. Create student class Student, inherit Person, contain : 1) Member variable : Student number stuId(String) 2) Construction method :Student(4 Parameters
){ super Overshoot class 3 Parametric structure , assignment stuId } 3. Create teacher class Teacher, inherit Person, contain : 1) Member variable : wages salary(double) 2)
Construction method :Teacher(4 Parameters ){ super Overshoot class 3 Parametric structure , assignment salary } 4. Create Doctor class Doctor, inherit Person, contain : 1) Member variable : title
level(String) 2) Construction method :Doctor(4 Parameters ){ super Overshoot class 3 Parametric structure , assignment level } 5. Create test class Test,main in : 1)
Create student array stus, contain 3 Elements , Assign values to elements , Traverse the output name and say hello 2) Create teacher array tes, contain 3 Elements , Assign values to elements , Traverse the output name and say hello 3)
Create doctor array docs, contain 2 Elements , Assign values to elements , Traverse the output name and say hello

Technology
©2019-2020 Toolsou All rights reserved,
C++ of string of compare usage Python Study notes ( one )evo Tool usage problems ——Degenerate covariance rank, Umeyama alignment is not possibleRISC-V_GD32VF103-TIMER0 timer interrupt java Array subscript variable _Java Basic grammar : array be based on stm32 Control four-wheel trolley motor drive ( one ) be based on redis Design of liking function Software engineering career planning mysql Query random data by conditions _MySQL Random query of several qualified records centos7 install RabbitMq