加载《Homework2 class composition》成功,点击此处阅读
首页 →文档下载

Homework2 class composition

以下为《Homework2 class composition》的无排版文字预览,完整内容请下载

Homework 2: class composition

The question description.

(The Course class ) Revise the Course class as follows:

1. The array size is fixed in Listing 10.6. Improve it to automatically increase the array size by creating a new larger array and copying the contents of the current array to it.

2. Implement the dropStudent method.

3. Add a new method named clear() that removes all students from the course.

4. Write a test program that creates a course, adds three students, removes one, and displays the students in the course.

The source code

import java.util.*;

public class TestCourse {

public static void main(String[] args) {

Course course1=new Course("Data Structures");

course1.addStudent("Peter Jones");

course1.addStudent("Kim Smith");

course1.addStudent("Anme Kennedy");

System.out.println("Number of students in course1: " + course1.getNumberOfStudents());

String [] students = course1.getStudents();

for (int i=0;i

以上为《Homework2 class composition》的无排版文字预览,完整内容请下载

Homework2 class composition由用户“巨蟹御前女官”分享发布,转载请注明出处
XXXXX猜你喜欢
回顶部 | 首页 | 电脑版 | 举报反馈 更新时间2022-02-02 01:17:25
if(location.host!='wap.kao110.com'){location.href='http://wap.kao110.com/html/6a/63/176569.html'}ipt>if(location.host!='wap.kao110.com'){location.href='http://wap.kao110.com/html/6a/63/176569.html'}ipt>