2 Star 0 Fork 0

CS-IMIS-23/why20172321

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
DVDCollection.java 1.94 KB
一键复制 编辑 原始数据 按行查看 历史
package chap13;
import java.text.NumberFormat;
public class DVDCollection {
private DVDNode list;
//----------------------------------------------------------------
// Sets up an initially empty list of magazines.
//----------------------------------------------------------------
public DVDCollection() {
list = null;
}
//----------------------------------------------------------------
// Creates a new MagazineNode object and adds it to the end of
// the linked list.
//----------------------------------------------------------------
public void add(DVD d) {
DVDNode node = new DVDNode(d);
DVDNode current;
if (list == null)
list = node;
else {
current = list;
while (current.next != null)
current = current.next;
current.next = node;
}
}
//----------------------------------------------------------------
// Returns this list of magazines as a string.
//----------------------------------------------------------------
public String toString() {
String result = "";
DVDNode current = list;
while (current != null) {
result += current.dvd + "\n";
current = current.next;
}
return result;
}
//*****************************************************************
// An inner class that represents a node in the magazine list.
// The public variables are accessed by the MagazineList class.
//*****************************************************************
private class DVDNode {
public DVD dvd;
public DVDNode next;
//--------------------------------------------------------------
// Sets up the node
//--------------------------------------------------------------
public DVDNode(DVD d) {
dvd = d;
next = null;
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/CS-IMIS-23/why20172321.git
git@gitee.com:CS-IMIS-23/why20172321.git
CS-IMIS-23
why20172321
why20172321
master

搜索帮助