gpt4 book ai didi

java hw 需要帮助才能理解

转载 作者:行者123 更新时间:2023-11-30 04:39:32 25 4
gpt4 key购买 nike

我先把整个问题写下来。

A ring is a collection of items that has a reference to a current item. An operation -- let's call it advance--moves the reference to the next item in the collection. When the reference reaches the last item, the next advance operation will move the reference back to the first item. A ring also has operations to get the current item, add an item, and remove an item. The details of where an item is added and which one is removed are up to you.

Design an ADT(Abstract Data Type) to represent a ring of objects. Specify each operation by stating its purpose, by describing its parameters, and by writing a pseudocode version of its header. Then write a Java interface for a ring's methods. Include javadoc-style comments in your code.

也就是说,Ring 就像一个带有操作的类,可以通过使用 T = items 这样的引用变量来移动项目? Advance 会在每次调用时更改 T 以代表不同的项目?类似 UML 格式的东西......

ADT:环

+advance(): T // move T to next item in collection and if T reaches last item, move T back to the first item.

+getCurrItem(): T // return item that T reference.

+addItem(item T): void // add an item in for T, No return.

+removeItem(Item: T): boolean // remove item that T reference and return true | false if it succeed or not.

我走在正确的道路上还是应该做点别的事情?

最佳答案

这对我来说似乎是一个好的开始。现在您必须致力于设计 ADT 以及您认为将如何存储项目并从末尾引用开头。这是一个数据抽象问题,您可以通过多种方式来实现,但如何高效地设计它取决于您。

关于java hw 需要帮助才能理解,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12643086/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com