Skip to content

Commit

Permalink
Format code with google-java-format
Browse files Browse the repository at this point in the history
This commit fixes the style issues introduced in 6a20796 according to the output
from google-java-format.

Details: https://deepsource.io/gh/xygglk/deepSourceTest/transform/83185512-d73c-4804-995b-6634497d0f8f/
  • Loading branch information
deepsource-autofix[bot] committed Feb 6, 2023
1 parent 6a20796 commit 0511a96
Show file tree
Hide file tree
Showing 9 changed files with 279 additions and 325 deletions.
92 changes: 43 additions & 49 deletions src/main/java/Butcher.java
Original file line number Diff line number Diff line change
@@ -1,58 +1,52 @@
/**
* Butcher 屠夫类
*/
/** Butcher 屠夫类 */
public class Butcher {
String name;//名字
String description;//描述
String age;//年龄
String address;//地址
String name; // 名字
String description; // 描述
String age; // 年龄
String address; // 地址

/**
* 屠夫的无参构造方法 在别的地方可以用new Butcher() 拿到一个屠夫对象
*/
public Butcher() {
System.out.println("调用屠夫类无参构造");
}
/** 屠夫的无参构造方法 在别的地方可以用new Butcher() 拿到一个屠夫对象 */
public Butcher() {
System.out.println("调用屠夫类无参构造");
}

public Butcher(String name, String description, String age, String address) {
this.name = name;
this.description = description;
this.age = age;
this.address = address;
System.out.println("调用屠夫类有参构造:Butcher(String, String, String, String)");
}
public Butcher(String name, String description, String age, String address) {
this.name = name;
this.description = description;
this.age = age;
this.address = address;
System.out.println("调用屠夫类有参构造:Butcher(String, String, String, String)");
}

public Butcher(String name) {
this.name = name;
System.out.println("调用屠夫类有参构造:Butcher(String) ");
}
public Butcher(String name) {
this.name = name;
System.out.println("调用屠夫类有参构造:Butcher(String) ");
}

/**
* 屠夫自我介绍方法
*/
public void selfIntroduction(String name, String description, String age, String address) {
System.out.println("我是一个屠夫,我叫" + name + "。");
}
/** 屠夫自我介绍方法 */
public void selfIntroduction(String name, String description, String age, String address) {
System.out.println("我是一个屠夫,我叫" + name + "。");
}

/**
* 杀猪方法
*
* @param pig
*/
public void killPig(Pig pig) {
System.out.println("杀掉这头名字为" + pig.getName() + "的猪");
}
/**
* 杀猪方法
*
* @param pig
*/
public void killPig(Pig pig) {
System.out.println("杀掉这头名字为" + pig.getName() + "的猪");
}

/**
* 销售猪肉方法 一斤猪肉卖10块
*
* @return
*/
public int sellPorkGetMoney(Pig pig) {
int wight = pig.getWight();//拿到猪被设置的重量
if (wight != 0) {//猪重量不为0 才乘以单价
return wight * 10;
}
return 0;//猪重量为0 卖出0块钱
/**
* 销售猪肉方法 一斤猪肉卖10块
*
* @return
*/
public int sellPorkGetMoney(Pig pig) {
int wight = pig.getWight(); // 拿到猪被设置的重量
if (wight != 0) { // 猪重量不为0 才乘以单价
return wight * 10;
}
return 0; // 猪重量为0 卖出0块钱
}
}
69 changes: 35 additions & 34 deletions src/main/java/Exam.java
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@
public class Exam {
public static void main(String[] args) {
Outter outter = new Outter();
outter.new Inner().print();
outter.new Inner().testIf(false);
}
public static void main(String[] args) {
Outter outter = new Outter();
outter.new Inner().print();
outter.new Inner().testIf(false);
}
}

class Outter {
private int a = 1;
private int a = 1;

class Inner {
private int a = 2;
class Inner {
private int a = 2;

public void print() {
int a = 3;
System.out.println("局部变量:" + a);//3
System.out.println("内部类变量:" + this.a);//2
System.out.println("外部类变量: " + Outter.this.a);//1
}
public void print() {
int a = 3;
System.out.println("局部变量:" + a); // 3
System.out.println("内部类变量:" + this.a); // 2
System.out.println("外部类变量: " + Outter.this.a); // 1
}

public void testIf(boolean bool) {
System.out.println("222222222222222222222222222222222");System.out.println(a);//这个地方是类变量不是下一行的变量 2
String a = "A";
String c;
if (bool) {
String b = "B";
c = "C";
System.out.println("++++++++++++++++++true++++++++++++++");
System.out.println(a);//A
System.out.println(b);//B
} else {
String b = "BB";
c = "CC";
System.out.println("==================false================");
System.out.println(a);//A
System.out.println(b);//BB
}
// System.out.println(b);//b是if括号里面定义的变量 外面取不到
System.out.println(c);//c是定义在括号外面 这里也是括号外面也能取到值
}
public void testIf(boolean bool) {
System.out.println("222222222222222222222222222222222");
System.out.println(a); // 这个地方是类变量不是下一行的变量 2
String a = "A";
String c;
if (bool) {
String b = "B";
c = "C";
System.out.println("++++++++++++++++++true++++++++++++++");
System.out.println(a); // A
System.out.println(b); // B
} else {
String b = "BB";
c = "CC";
System.out.println("==================false================");
System.out.println(a); // A
System.out.println(b); // BB
}
// System.out.println(b);//b是if括号里面定义的变量 外面取不到
System.out.println(c); // c是定义在括号外面 这里也是括号外面也能取到值
}
}
}

0 comments on commit 0511a96

Please sign in to comment.