這題目設(shè)計(jì)的Lady類有點(diǎn)多此一舉,代碼如下:

成都創(chuàng)新互聯(lián)公司主營(yíng)宕昌網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,app軟件開(kāi)發(fā)公司,宕昌h5成都微信小程序搭建,宕昌網(wǎng)站營(yíng)銷推廣歡迎宕昌等地區(qū)企業(yè)咨詢
public?abstract?class?Animal?{
private?String?name;
public?Animal(String?name){
this.name?=?name;
}
abstract?void?enjoy();
}
public?class?Dog?extends?Animal?{
private?String?hair_color;
public?Dog(String?name,?String?hair_color)?{
super(name);
this.hair_color?=?hair_color;
}
@Override
void?enjoy()?{
System.out.println("汪汪汪~(yú)");
}
}
public?class?Cat?extends?Animal?{
private?String?eyes_color;
public?Cat(String?name,?String?eyes_color)?{
super(name);
this.eyes_color?=?eyes_color;
}
@Override
void?enjoy()?{
System.out.println("喵喵喵~");
}
}
public?class?Lady?{
private?String?name;
private?Animal[]?pets;
public?Lady(String?name,?Animal[]?pets)?{
this.name?=?name;
this.pets?=?pets;
}
public?void?myPetEnjoy(){
for?(int?i?=?0;?i??pets.length;?i++)?{
pets[i].enjoy();
}
}
}
public?class?TestAnimal?{
public?static?void?main(String[]?args)?{
Cat?cat?=?new?Cat("小黑狗",?"黑色");
Dog?dog?=?new?Dog("小花貓",?"黃色");
Animal[]?pets?=?{cat,?dog};
Lady?lady?=?new?Lady("張三",?pets);
lady.myPetEnjoy();
}
}
//輸出如下:
喵喵喵~
汪汪汪~(yú)
上面 wuzhikun12同學(xué)寫(xiě)的不錯(cuò),但我想還不能運(yùn)行,并且還不太完善。我給個(gè)能運(yùn)行的:(注意:文件名為:Test.java)
//要實(shí)現(xiàn)對(duì)象間的比較,就必須實(shí)現(xiàn)Comparable接口,它里面有個(gè)compareTo方法
//Comparable最好使用泛型,這樣,無(wú)論是速度還是代碼量都會(huì)減少
@SuppressWarnings("unchecked")
class Student implements ComparableStudent{
private String studentNo; //學(xué)號(hào)
private String studentName; //姓名
private double englishScore; //英語(yǔ)成績(jī)
private double computerScore; //計(jì)算機(jī)成績(jī)
private double mathScore; //數(shù)學(xué)成績(jī)
private double totalScore; //總成績(jī)
//空構(gòu)造函數(shù)
public Student() {}
//構(gòu)造函數(shù)
public Student(String studentNo,String studentName,double englishSocre,double computerScore,double mathScore) {
this.studentNo = studentNo;
this.studentName = studentName;
this.englishScore = englishSocre;
this.computerScore = computerScore;
this.mathScore = mathScore;
}
//計(jì)算總成績(jī)
public double sum() {
this.totalScore = englishScore+computerScore+mathScore;
return totalScore;
}
//計(jì)算評(píng)測(cè)成績(jī)
public double testScore() {
return sum()/3;
}
//實(shí)現(xiàn)compareTO方法
@Override
public int compareTo(Student student) {
double studentTotal = student.getTotalScore();
return totalScore==studentTotal?0:(totalScorestudentTotal?1:-1);
}
//重寫(xiě)toString方法
public String toString(){
return "學(xué)號(hào):"+this.getStudentNo()+" 姓名:"+this.getStudentName()+" 英語(yǔ)成績(jī):"+this.getEnglishScore()+" 數(shù)學(xué)成績(jī):"+this.getMathScore()+" 計(jì)算機(jī)成績(jī):"+this.getComputerScore()+" 總成績(jī):"+this.getTotalScore();
}
//重寫(xiě)equals方法
public boolean equals(Object obj) {
if(obj == null){
return false;
}
if(!(obj instanceof Student)){
return false;
}
Student student = (Student)obj;
if(this.studentNo.equals(student.getStudentName())) { //照現(xiàn)實(shí)來(lái)說(shuō),比較是不是同一個(gè)學(xué)生,應(yīng)該只是看他的學(xué)號(hào)是不是相同
return true;
} else {
return false;
}
}
/*以下為get和set方法,我個(gè)人認(rèn)為,totalScore的set的方法沒(méi)必要要,因?yàn)樗怯善渌煽?jī)計(jì)算出來(lái)的
在set方法中,沒(méi)設(shè)置一次值,調(diào)用一次sum方法,即重新計(jì)算總成績(jī)
*/
public String getStudentNo() {
return studentNo;
}
public void setStudentNo(String studentNo) {
this.studentNo = studentNo;
sum();
}
public String getStudentName() {
return studentName;
}
public void setStudentName(String studentName) {
this.studentName = studentName;
sum();
}
public double getEnglishScore() {
return englishScore;
}
public void setEnglishScore(double englishScore) {
this.englishScore = englishScore;
sum();
}
public double getComputerScore() {
return computerScore;
}
public void setComputerScore(double computerScore) {
this.computerScore = computerScore;
sum();
}
public double getMathScore() {
return mathScore;
}
public void setMathScore(double mathScore) {
this.mathScore = mathScore;
sum();
}
public double getTotalScore() {
return totalScore;
}
}
//Student子類學(xué)習(xí)委員類的實(shí)現(xiàn)
class StudentXW extends Student {
//重寫(xiě)父類Student的testScore()方法
@Override
public double testScore() {
return sum()/3+3;
}
public StudentXW() {}
//StudentXW的構(gòu)造函數(shù)
public StudentXW(String studentNo,String studentName,double englishSocre,double computerScore,double mathScore) {
super(studentNo,studentName,englishSocre,computerScore,mathScore);
}
}
//Student子類班長(zhǎng)類的實(shí)現(xiàn)
class StudentBZ extends Student {
//重寫(xiě)父類Student的testScore()方法
@Override
public double testScore() {
return sum()/3+5;
}
public StudentBZ() {}
//StudentXW的構(gòu)造函數(shù)
public StudentBZ(String studentNo,String studentName,double englishSocre,double computerScore,double mathScore) {
super(studentNo,studentName,englishSocre,computerScore,mathScore);
}
}
//測(cè)試類
public class Test {
public static void main(String[] args) {
//生成若干個(gè)student類、StudentXW類、StudentBZ類
Student student1 = new Student("s001","張三",70.5,50,88.5);
Student student2 = new Student("s002","李四",88,65,88.5);
Student student3 = new Student("s003","王五",67,77,90);
StudentXW student4 = new StudentXW("s004","李六",99,88,99.5);
StudentBZ student5 = new StudentBZ("s005","朱漆",56,65.6,43.5);
Student[] students = {student1,student2,student3,student4,student5};
for(int i = 0 ; istudents.length; i++){
double avgScore = students[i].testScore();
System.out.println(students[i].getStudentName()+"學(xué)生的評(píng)測(cè)成績(jī)?yōu)椋?+ avgScore+"分");
}
}
}
運(yùn)行結(jié)果為:
張三學(xué)生的評(píng)測(cè)成績(jī)?yōu)椋?9.66666666666667分
李四學(xué)生的評(píng)測(cè)成績(jī)?yōu)椋?0.5分
王五學(xué)生的評(píng)測(cè)成績(jī)?yōu)椋?8.0分
李六學(xué)生的評(píng)測(cè)成績(jī)?yōu)椋?8.5分
朱漆學(xué)生的評(píng)測(cè)成績(jī)?yōu)椋?0.03333333333333分
既然是商品庫(kù)存系統(tǒng),那么最少有各種商品的單件信息,1:需要有商品的進(jìn)貨價(jià)格,賣(mài)出價(jià)格,剩余數(shù)量,每月的銷售數(shù)量,進(jìn)貨時(shí)間等,在對(duì)應(yīng)的數(shù)據(jù)庫(kù)表創(chuàng)建相應(yīng)的字段。2:商品管理就是對(duì)多種商品的管理,所以還要有各種商品的分類,比如煙酒類,飲料類,小吃類,將其分類好管理,同樣數(shù)據(jù)庫(kù)里面建立相對(duì)的數(shù)據(jù)表。具體需要根據(jù)自己需求來(lái)編寫(xiě)。3:界面的設(shè)計(jì),這里可分為登陸界面,其中一個(gè)是用戶登陸后查看的界面,和管理員登陸后查看的界面,用戶登錄只能查看對(duì)應(yīng)的商店的物品管理,并且能進(jìn)行修改自家商品。管理員登陸可查看所有的用戶的商店物品,及修改物品信息。而物品分類欄就可以用jQuery來(lái)實(shí)現(xiàn)局部的刷新界面。左邊為物品分類欄,右邊為選中物品類的信息。點(diǎn)擊右邊分類物品的某件物品,可跳轉(zhuǎn)到該類物品的單個(gè)信息,如第1點(diǎn)提到的。
打印值的是連接打印機(jī)來(lái)打印吧?
可以在后臺(tái)對(duì)出庫(kù)單進(jìn)行拼裝顯示到頁(yè)面,然后利用IE提供的方法進(jìn)行打印當(dāng)前頁(yè)來(lái)打印。。。
還有就是可以利用商業(yè)軟件來(lái)實(shí)現(xiàn),實(shí)現(xiàn)方式也和IE差不多,后臺(tái)拼裝數(shù)據(jù) 前臺(tái)調(diào)用插件打印數(shù)據(jù),相比ie要更近靈活,方便 (IE打印會(huì)彈出一個(gè)選擇框讓用戶選擇)
我推薦你使用lodop 找下這個(gè)。免費(fèi)的 開(kāi)發(fā)者也有提供API (如果商用建議購(gòu)買(mǎi) 也很便宜)
可以這么考慮!商品類
publicGoods{
privateintnum;//商品編號(hào)
privateStringname;//商品名稱
privateStringwhen;//出廠日期
privateStringfactory;//商家
//構(gòu)造方法
publicGoods(){
}
publicGoods(intnum,Stringname,Stringwhen,Stringfactory){
this.num=num;
this.name=name;
this.when=when;
this.factory=factory;
}
//省略四種屬性的setter和getter方法(快捷鍵shift+alt+s+r)
}
食品類
publicFoodsextendsGoods{
privateStringbadtime;//保質(zhì)期
privateStringmade;//成分
//構(gòu)造方法
publicFoods(){
}
publicFoods(intnum,Stringname,Stringwhen,Stringfactory,Stringbadtime,Stringmade){
super(num,name,when,factory);
this.badtime=badtime;
this.made=made;
}
//省略兩種屬性的setter和getter方法
}
服裝類
publicClothesextendsGoods{
privateStringtype;//型號(hào)
privateStringwhat;//面料
//構(gòu)造方法
publicClothes(){
}
publicClothes(intnum,Stringname,Stringwhen,Stringfactory,Stringtype,Stringwhat){
super(num,name,when,factory);
this.type=type;
this.what=what;
}
//省略兩種屬性的setter和getter方法
}
這就是你需求的父類和繼承父類的子類。至于允許,你要根據(jù)要求創(chuàng)建測(cè)試類。
父類和子類是不能運(yùn)行出結(jié)果的。
本文名稱:java服裝設(shè)計(jì)出庫(kù)代碼,java服裝設(shè)計(jì)出庫(kù)代碼是多少
本文鏈接:http://chinadenli.net/article43/dsshohs.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT、面包屑導(dǎo)航、網(wǎng)站建設(shè)、軟件開(kāi)發(fā)、虛擬主機(jī)、手機(jī)網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)