<> Object oriented first day :

<> First day of submarine game :

* establish 6 Class , establish World Class and test
<> review :

*
array :

*
copy :

*
System.arraycopy(a,1,b,0,4);

*
int[] b = Arrays.copyOf(a,6);

a = Arrays.copyOf(a,a.length+1);

*
sort :

* Arrays.sort(arr);
*
method : function , process

​ Encapsulate a specific business logic function , Just do one thing , Can be called repeatedly ,

​ Reduce code duplication , It is conducive to code reuse , It is conducive to code maintenance

*
Definition of method :

​ Modifier return type Method name ( parameter list ) {

​ Method body

​ }

*
Method call :

* No return value : Method name ( There is a reference to pass on a reference );
* There is a return value : data type variable = Method name ( There is a reference to pass on a reference );
*
return:

* return value ; //1) End method 2) Returns the result to the caller
* return; //1) End method
<> note :

*
What is a class ? What is an object ?

*
Real life is made up of many objects , Classes are extracted based on objects

*
object : A real individual in software / thing

class : category / type , Represents a class of individuals

*
A class is a model of an object , An object is a concrete instance of a class

*
Class can contain :

* Object properties / features ----------------------- Member variable
* Object behavior / action ----------------------- method
*
A class can create multiple objects

*
How to create a class ? How to create objects ? How to access members ?
public class Student { //Student Class is a reference type we make ourselves // Member variable String name; int age;
String address; // method void study(){ System.out.println(name+" I'm learning ..."); } void
sayHi(){ System.out.println(" hello everyone , My name is "+name+", this year "+age+" Years old , Live at home "+address); } } public
class StudentTest { public static void main(String[] args){ // Create a student object Student
zs= new Student(); // Assign values to member variables zs.name = "zhangsan"; zs.age = 25; zs.address =
" Langfang, Hebei "; // Call method zs.study(); zs.sayHi(); Student ls = new Student(); ls.name =
"lisi"; ls.age = 24; ls.address = " Jiamusi, Heilongjiang "; ls.study(); ls.sayHi();
//1) Created a student object //2) Assign default values to all member variables Student ww = new Student(); ww.study(); ww.sayHi()
; } }
*
Overloading of methods (overload/overloading):--------------- More user-friendly access

* Occurs in the same class , Same method name , The parameter list is different
* The compiler will automatically bind the method according to its signature at compile time // Overloaded demo public class OverloadDemo { public static void
main(String[] args) { Aoo o = new Aoo(); o.show(); // The compiler automatically binds a method based on its signature o.show(
"zhangsan"); o.show(25); o.show("zhangsan",25); o.show(25,"zhangsan"); } } class
Aoo{ void show(){} void show(String name){} void show(int age){} void show(
String name,int age){} void show(int age,String name){} //int show(){ return
1;} // Compilation error , Overloading is independent of the return value type //void show(String address){} // Compilation error , Overloading is independent of parameter names }
<> Essence note :

*
What is a class ? What is an object ?

*
Real life is made up of many objects , Classes are extracted based on objects

*
object : A real individual in software / thing

class : category / type , Represents a class of individuals

*
A class is a model of an object , An object is a concrete instance of a class

*
Class can contain :

* Object properties / features ----------------------- Member variable
* Object behavior / action ----------------------- method
*
A class can create multiple objects

*
How to create a class ? How to create objects ? How to access members ?

*
Overloading of methods (overload/overloading):--------------- More user-friendly access

* Occurs in the same class , Same method name , The parameter list is different
* The compiler will automatically bind the method according to its signature at compile time
<> Submarine game demand :

* Roles involved :
* warship , Deep water bomb , Reconnaissance submarine , Torpedo submarine , Mine submarine , mine
* Relationship between roles :
* The warship fired a deep-water bomb
* Deep water bombs can hit submarines ( Reconnaissance submarine , Torpedo submarine , Mine submarine ), If hit :
* The submarine disappeared , The deep-water bomb disappeared
* Get something :
* Destroy the reconnaissance submarine , Players get 10 branch
* Destroy the torpedo submarine , Players get 40 branch
* Knock down the mine submarine , Warship 1 Life
* Mine submarines can launch mines
* Mines can hit warships , If hit :
* The mine disappeared
* Warship reduction 1 Life ( Destiny is 0 At the end of the game )
supplement :

*
High quality code :--------------------- Future goals , Get an annual salary

* Good reusability , Good scalability , Good maintainability , Good portability \ Good robustness , Good readability , Good efficiency …
*
Default value rule :
byte,short,int,long,char-------------0 float,double-------------------------0.0
boolean------------------------------false reference type ------------------------------
null
* // To access an object , Reference required zs quote data type Reference type variable point object Student zs = new Student();
*
Method signature : Method name + parameter list

*
Tomorrow words :
1)this: this 2)Pointer: Pointer 3)random: random 4)reference: quote

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