在我发布我的问题之前,我只需要关于如何改进我的java程序的指导,因为我想学习。
因此,对于我的作业,我需要:
我和我的团队课搞混了。我不知道如何在类中添加11个播放器,并为播放器实例提供一个输入参数。我不确定我的app类,因为我不知道如何使用football team实例(对象)来显示实验室中请求的信息。
这是我目前所掌握的
public class app {
public static void main(String[] args)
{
player pl1 = new player
("Christian","Campbell","Cornerback","Alabama","Central");
System.out.println(pl1.getInfo());
player pl2 = new player
("Marcus","Allen","Safety","Maryland","Dr. Henry A. Wise, Jr");
System.out.println(pl2.getInfo());
player pl3 = new player
("Tommy","Stevens","Quarterback","Indiana","Decatur Central");
System.out.println(pl3.getInfo());
player pl4 = new player
("Nyeem","Wartman-White", "Linebacker","Pennsylvania","Valley View");
System.out.println(pl4.getInfo());
player pl5 = new player
("George", "Foreman", "Defensive back","Georgia","Parkview");
System.out.println(pl5.getInfo());
player pl6 = new player
("Andre","Robinson","Right Tackle","Pennsylvania","Bishop McDevitt");
System.out.println(pl6.getInfo());
player pl7 = new player
("Malik","Golden","Safety","Connecticut","Chesire Academy");
System.out.println(pl7.getInfo());
player pl8 = new player
("Koa","Farmer","Safety","California","Notre Dame");
System.out.println(pl8.getInfo());
player pl9 = new player
("Jake","Zembiec","Quarterback","New York","Aquinas Institute");
System.out.println(pl9.getInfo());
player pl10 = new player
("Brandon","Polk","Wide Receiver","Virgina","Briar Woods");
System.out.println(pl10.getInfo());
player pl11 = new player
("Trace","McSorley","Quarterback","Virgina","Briar Woods");
System.out.println(pl11.getInfo());
}
}
public class player {
//---------Declaring attributes----
String firstName;
String lastName;
String position;
String State;
String Highschool;
player (String inf_firstName, String inf_lastName, String inf_position, String inf_State, String inf_Highschool)
{
firstName = inf_firstName;
lastName = inf_lastName;
position = inf_position;
State = inf_State;
Highschool = inf_Highschool;
}
String getInfo()
{
return "Name: "+firstName+ " "+lastName+", "+"position: " +position+ ", State: " +State+ ", High School: " +Highschool;
}
}
public class team {
String team = "Penn State";
String mascot = "Nittany Lions";
team(String inf_team, String inf_mascot)
{
team = inf_team;
mascot = inf_mascot;
}
team t1 = new team("Penn State", "Nittany Lions");
String getInfo()
{
return "Team Name: "+team+ "Team Mascot: "+mascot;
}
}
在team类中,在String team和String mascot下面,需要一个Player[]players数组。在构造函数中,传入包含所有播放器的数组。
桌上足球 可以将普通桌上足球改造成可社交化的智能产品。通过微信邀约好友参加比赛,实时显示比分,微信分享比赛结果,还可以实时拍摄赛况。
行为型模式(下) 意大利昨晚太杯具了!!!不说了,继续把最后一部分写完。 (18) 备忘录模式:足球是圆的,一切皆有可能发生。要是有后悔药的话,如果能回到昨晚2012年欧洲杯决赛的中场休息,我相信普兰德利一定不会用莫塔换下蒙托利沃;如果能回到昨晚比赛开始,我相信一开始就不会让基耶利尼上场,如果能回到......(再回可能意大利就被德国淘汰了,)能回到吗?回不到哦,要是能回到过
行为型模式(上) (13) 职责链模式:布冯手抛球给基耶利尼、基耶利尼传给皮尔洛、皮尔洛带球过人之后将球直塞给快速插上的巴洛特利,巴洛特利倒钩射门,球进了,球进了,又是巴洛特利,巴洛特利立功了,伟大的意大利前锋!他继承了意大利的光荣传统,巴乔、因扎吉、皮耶罗在这一刻灵魂附体!巴洛特利代表了意大利足球悠久的历史和传统,在这一刻他不是一个人在战斗,他不是一个人! 在此
结构型模式 (6) 适配器模式:很多足球队都喜欢请外国教练(其中有一支我们都非常熟悉的国家队,名字偶就不说了,大家都懂的,),外国教练请回来通常很难跟队员直接交流(语言不通),因此需要配翻译,此时,翻译充当了教练和队员之间的适配器,负责协调教练和队员之间的交流。 例如:pass --> shoot --> goal 转换 传球 --> 射门 --> 进球 适
今天晚上2012年欧洲杯决赛(西班牙 VS 意大利),作为一名铁杆球迷,偶当然不会错过(请不要让我来预测比分,我不是章鱼,更何况这两个队我都非常喜欢,输赢我都很淡定,),在静候决赛的这段时间,突然萌发一个想法,将设计模式跟足球联系到一起写点啥,就像当年那篇知名度极高的《追MM与设计模式》一样,以供娱乐!,话不多说,即刻动手! 创建型模式 (1) 工厂方法模
一、初识类和对象 Scala 的类与 Java 的类具有非常多的相似性,示例如下: // 1. 在 scala 中,类不需要用 public 声明,所有的类都具有公共的可见性 class Person { // 2. 声明私有变量,用 var 修饰的变量默认拥有 getter/setter 属性 private var age = 0 // 3.如果声明的变量不需要进行初始赋值,此