北有风雪

# 序言

## 第1章. 故事的缘起

``````public class Student {
private String name = null;

public Student(String name) {
// TODO Auto-generated constructor stub
this.name = name;
}

public void setName(String name) {
this.name = name;
}

private int calcADD(int a, int b) {
return a + b;
}

public void fillBlank(int a, int b) {
System.out.println(name + "心算:" + a + " + " + b + " = " + result);
}
}``````

``````public class Test {
public static void main(String[] args) {
int a = 1;
int b = 1;
Student s = new Student("小明");
s.fillBlank(a, b);
}
}``````

``小明心算:1 + 1 = 2``

## 第2章. 幼师的找茬

``````public class Calculator {
public int add(int a, int b) {
return a + b;
}
}``````

``````public class Student {
private String name = null;

public Student(String name) {
// TODO Auto-generated constructor stub
this.name = name;
}

public void setName(String name) {
this.name = name;
}

private int calcADD(int a, int b) {
return a + b;
}

private int useCalculator(int a, int b) {
}

public void fillBlank(int a, int b) {
int result = useCalculator(a, b);
System.out.println(name + "使用计算器:" + a + " + " + b + " = " + result);
}
}``````

``````public class Test {
public static void main(String[] args) {
int a = 168;
int b = 291;
Student s = new Student("小明");
s.fillBlank(a, b);
}
}``````

``小明使用计算器:168 + 291 = 459``

## 第3章. 幼师回来了

``````public class SuperCalculator {
public void add(int a, int b, Student  xiaoming) {
int result = a + b;
xiaoming.fillBlank(a, b, result);
}
}``````

``````public class Student {
private String name = null;

public Student(String name) {
// TODO Auto-generated constructor stub
this.name = name;
}

public void setName(String name) {
this.name = name;
}

public void callHelp (int a, int b) {
}

public void fillBlank(int a, int b, int result) {
System.out.println(name + "求助小红计算:" + a + " + " + b + " = " + result);
}
}``````

``````public class Test {
public static void main(String[] args) {
int a = 26549;
int b = 16487;
Student s = new Student("小明");
s.callHelp(a, b);
}
}``````

``小明求助小红计算:26549 + 16487 = 43036``

## 第4章. 门口的婆婆

``````public interface doJob {
public void fillBlank(int a, int b, int result);
}``````

``````public class SuperCalculator {
public void add(int a, int b, doJob  customer) {
int result = a + b;
customer.fillBlank(a, b, result);
}
}``````

``````public class Student {
private String name = null;

public Student(String name) {
// TODO Auto-generated constructor stub
this.name = name;
}

public void setName(String name) {
this.name = name;
}

public class doHomeWork implements doJob {

@Override
public void fillBlank(int a, int b, int result) {
// TODO Auto-generated method stub
System.out.println(name + "求助小红计算:" + a + " + " + b + " = " + result);
}

}

public void callHelp (int a, int b) {
}
}``````

``````public class Seller {
private String name = null;

public Seller(String name) {
// TODO Auto-generated constructor stub
this.name = name;
}

public void setName(String name) {
this.name = name;
}

public class doHomeWork implements doJob {

@Override
public void fillBlank(int a, int b, int result) {
// TODO Auto-generated method stub
System.out.println(name + "求助小红算账:" + a + " + " + b + " = " + result + "元");
}

}

public void callHelp (int a, int b) {
}
}``````

``````public class Test {
public static void main(String[] args) {
int a = 56;
int b = 31;
int c = 26497;
int d = 11256;
Student s1 = new Student("小明");
Seller s2 = new Seller("老婆婆");

s1.callHelp(a, b);
s2.callHelp(c, d);
}
}``````

``小明求助小红计算:56 + 31 = 87 老婆婆求助小红算账:26497 + 11256 = 37753``

### 北有风雪

【目录导航】JAVA零基础进阶之路

【JAVA零基础入门系列】（已完结）导航目录 Day1 开发环境搭建 Day2 Java集成开发环境IDEA Day3 Java基本数据类型 Day4 变量与常量 Day5 Java中的运算符 Day6 Java字符串 Day7 Java输入与输出...

MFrank
2018/06/21
0
0
Android进程间通信（一）：AIDL使用详解

04/06
0
0
Kafka与操作系统适配性研究

analanxingde
04/24
0
0

01/25
342
0
Guava 源码分析（Cache 原理【二阶段】）

crossoverJie
2018/07/16
0
0

Excel数据透视表基础：数据透视表的正确数据格式

1.数据透视表：是一种数据分析方法， 一.使用数据透视表必须用正确的数据格式： 1.数据必须有标题： 2.数据表不能有相同的标题 3.数据表中不能有合并单元格 4.不能有 小计、合计、空行、分类...

7分钟前
1
0

go4it
40分钟前
4
0

45分钟前
7
0

linuxCool

3
0

5
0