package VersionTwo;
public class StuList implements MyList
{
private Student[] stu;
private int length; //实际容量
public StuList(int len)
{
stu=new Student[len]; //数组可变长
this.length=0;
}
private boolean isOverflow() //辅助方法,判断数组是否溢出
{
if(this.length<stu.length)
return false;
else
return true;
}
public boolean isEmpty() //判断数组是否为空
{
return this.length==0;
}
public boolean addStu(Student x) //添加学生信息
{
if(isOverflow())
return false;
stu[length++]=x;
return true;
}
public Student removeStu(int index) //删除指定位置的学生信息
{
if(isEmpty())
{
System.out.println("学生表空的~~~删除失败~~~~");
return null;
}
Student temp=stu[index-1];
for(int i=index-1;i<this.length-1;i++)
{
stu[i]=stu[i+1];
}
this.length--;
return temp;
}
public void sort(int x) //按照成绩排序,参数1按数学排序,参数2按计算机排序
{
if(x==1)
{
for(int i=0;i<this.length-1;i++)
{
for(int j=0;j<this.length-i-1;j++)
{
if(stu[j].getMathScore()<stu[j+1].getMathScore())
{
Student t=stu[j];
stu[j]=stu[j+1];
stu[j+1]=t;
}
}
}
}
else if(x==2)
{
for(int i=0;i<this.length-1;i++)
{
for(int j=0;j<this.length-i-1;j++)
{
if(stu[j].getComputerScore()<stu[j+1].getComputerScore())
{
Student t=stu[j];
stu[j]=stu[j+1];
stu[j+1]=t;
}
}
}
}
}
public void print()
{
if(stu[0] instanceof Undergraduate)
System.out.println("学号\t姓名\t数学\t计算机");
else
System.out.println("学号\t姓名\t数学\t计算机\t导师\t研究方向");
for(int i=0;i<this.length;i++)
{
stu[i].print();
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
第一部分 根据“实验4说明”文件夹中给出的源程序MainTwo.java,StuList.java(其中的类实现了接口MyList),Student.java(其中的类Student是抽象类,其中,print( )方法是抽象方法)。 第二部分 编写一个类,该类的功能是可以根据给定的字符串(字符串中单词之间有空格)和子串,计算出字符串中包含多少个子串。(使用String类的方法。) 第三部分 编写一个类,该类的功能是可以根据给定的字符串(字符串中单词之间没有空格)和子串,计算出字符串中包含多少个子串。(使用String类的方法。) 这一部分的程序框架和第二部分相同,只是void countSubString(String s, String substring)方法的具体实现不同。
资源推荐
资源详情
资源评论






























收起资源包目录










共 8 条
- 1
资源评论


滑滑本滑
- 粉丝: 9
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 【微信小程序源码】供应商城.zip
- 【微信小程序源码】个人音乐台.zip
- 【微信小程序源码】购物节抽奖小程序.zip
- 【微信小程序源码】购物车.zip
- 【微信小程序源码】股票分时图K线图小程序.zip
- 【微信小程序源码】果库.zip
- 【微信小程序源码】光影娱乐带后台.zip
- 【微信小程序源码】和茶网.zip
- 【微信小程序源码】红包抽奖css3方式实现转盘.zip
- 【微信小程序源码】盒马鲜生.zip
- 【微信小程序源码】黑市商城框架.zip
- 【微信小程序源码】红包抽奖v02版.zip
- 【微信小程序源码】宏华水利小程序.zip
- 【微信小程序源码】户外旅游小程序.zip
- 【微信小程序源码】华云智慧园区.zip
- 【微信小程序源码】滑动选项卡.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
