Java 英文编程题【急】
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/11 08:44:42
Java 英文编程题【急】
Implement a class named textBook which has two attributes:pages for the
number of pages and title for the textbook’s title.Then write a derived class
mathBook which has two inherited attributes and two new attributes:definitions
and average.The definitions is an integer representing the number of defined
words in the mathBook.The average is:
number of definitions
number of pages
which is of type double.The class mathBook should also define a new method
getAverage() which prints and returns the average number of definitions per
page.
Implement a class named textBook which has two attributes:pages for the
number of pages and title for the textbook’s title.Then write a derived class
mathBook which has two inherited attributes and two new attributes:definitions
and average.The definitions is an integer representing the number of defined
words in the mathBook.The average is:
number of definitions
number of pages
which is of type double.The class mathBook should also define a new method
getAverage() which prints and returns the average number of definitions per
page.
class TextBox
{
TextBox(int pages,String title)
{
this.pages=pages;
this.title=title;
}
int pages;//页数
String title;//标题
}
class MathBook extends TextBox
{
MathBook(int d)
{
definitions=d;
}
int definitions;//定义过的word的数量
double average;//每页定义的word的平均数量
double getAverage()
{
return average=(double)definitions/page;
}
}
{
TextBox(int pages,String title)
{
this.pages=pages;
this.title=title;
}
int pages;//页数
String title;//标题
}
class MathBook extends TextBox
{
MathBook(int d)
{
definitions=d;
}
int definitions;//定义过的word的数量
double average;//每页定义的word的平均数量
double getAverage()
{
return average=(double)definitions/page;
}
}