作者:--郑煦桥-- | 来源:互联网 | 2023-10-12 13:09
java 、new 一个女朋友(小白瞎写)``
纯属娱乐欢迎来喷
打印结果如下
//源代码如下:
public class GirlFriend {
private String name;
private String eat;
private String sing;
private String shopping;
private String movie;
public GirlFriend(String name, String eat, String sing, String shopping, String movie) {
super();
this.name = name;
this.eat = eat;
this.sing = sing;
this.shopping = shopping;
this.movie = movie;
}
public GirlFriend() {
super();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEat() {
return eat;
}
public void setEat(String eat) {
this.eat = eat;
}
public String getSing() {
return sing;
}
public void setSing(String sing) {
this.sing = sing;
}
public String getShopping() {
return shopping;
}
public void setShopping(String shopping) {
this.shopping = shopping;
}
public String getMovie() {
return movie;
}
public void setMovie(String movie) {
this.movie = movie;
}
@Override
public String toString() {
return "和"+name+" 一起"+eat+"、"+shopping+sing+movie;
}
public static void heart() {
for (int i = 0, k = 0; i <14; i++) {
if (i <3) {
for (int j = 0; j <5 - 2 * i; j++) {
System.out.print(" ");
}
if (i == 2) {
for (int j = 0; j <6 + 4 * i - 1; j++) {
System.out.print("*");
}
for (int j = 0; j <7 - 4 * i + 2; j++) {
System.out.print(" ");
}
for (int j = 0; j <6 + 4 * i - 1; j++) {
System.out.print("*");
}
} else {
for (int j = 0; j <6 + 4 * i; j++) {
System.out.print("*");
}
for (int j = 0; j <7 - 4 * i; j++) {
System.out.print(" ");
}
for (int j = 0; j <6 + 4 * i; j++) {
System.out.print("*");
}
}
} else if (i <6) {
for (int j = 0; j <29; j++) {
System.out.print("*");
}
} else {
if (i == 13) {
for (int j = 0; j <2 * (i - 6); j++) {
System.out.print(" ");
}
System.out.print("*");
} else {
for (int j = 0; j <2 * (i - 6) + 1; j++) {
System.out.print(" ");
}
for (int j = 1; j <28 - 4 * k; j++) {
System.out.print("*");
}
k++;
}
}
System.out.println();
}
}
public class GirlFriendLove extends Heart {
public static void main(String[] args) {
// TODO Auto-generated method stub
GirlFriend girlFriend = new GirlFriend();
girlFriend.setName("小姐姐");
girlFriend.setEat("大餐");
girlFriend.setMovie("看电影");
girlFriend.setShopping("逛街");
girlFriend.setSing("唱歌");
System.out.println(girlFriend);
GirlFriend girlFriend1 = new GirlFriend("大姐姐", "吃饭", "唱歌", "逛街", "看电影");
System.out.println();
System.out.println(girlFriend1);
System.out.println();
heart();
}