- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我先把整个问题写下来。
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/
我需要用*制作一棵树,高度需要是用户插入的数字,再加上2个*作为额外的行,以及它的树干的1/3。 另外,最后一行之前不能有空格。我编写了整个代码,但最后一行也是最长的一行出现之前有一个空格.. 我哪里
我正在尝试编写一个函数来检测是否在数字中找到数字: // returns 1 if source contains num, 0 otherwise int contains_num(source,
我先把整个问题写下来。 A ring is a collection of items that has a reference to a current item. An operation --
以下是我遇到问题的作业。我意识到字符串 piglatin 未初始化,但我不确定如何为其设置变量。 import java.util.*; public class PigLatinHomework {
我对如何使用堆栈以及为什么我什至会在我编写的代码中使用堆栈有点困惑。该评估说要编写一个程序来检查用户输入是否格式正确。这是一个简单的程序,具有三种不同的选项供用户选择。 1. 基本括号 () 2. 标
我做了一个 N 个皇后的 java 项目,需要我打印一个多维数组,显示可以放置皇后的位置。我的数组是整数。它在合适的位置打印出 1 和 0。我想知道是否有一种方法可以在不将数组更改为 String 类
我们正在学习使用 JSOUP 和 urlconnection,因此我们正在解析我们选择的网站中的页面,并解析页面以回答有趣的问题。 一切正常,但是时不时地我会收到 SocketTimeOutExcep
这是为了研究,我只是想确保我的答案 100% 正确。问题给了我骨架代码,我需要填写它。这是代码。 public class WebFragment extends WebViewFragment {
已关闭。这个问题是 not reproducible or was caused by typos 。目前不接受答案。 这个问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-top
我需要计算一个float 数字的位数并保留该数字。我可以将 scanf() 与 %f 或 %c 一起使用,但不能将 %s 与 %s 一起使用,而且我可以使用 getchar()。 我可以使用 getc
在“AmDocs”最近组织的比赛中,我遇到了以下问题:(问题的基本思路) 给定一个大小固定为 12x12 的矩阵。给定六个长度为 6、5、5、4、3、2 的线段。矩阵有空的空间和填充的空间。您必须返回
我们遇到了一个问题,我将其简化为以下内容:给你一个全为 1 的二进制数(例如 11111)和一组相同长度的二进制数(00101、10000、01100、00100、11100)。有两个玩家 A 和 B
我正在做一项作业,但我不知道如何实现它。我必须做一个函数 sadd(int x, int y)返回加在一起的数字,除非它溢出(然后只返回最大可能的整数)。我已经能够想出一些涉及强制转换和条件语句的解决
对于家庭作业,我必须用 C 编写一个函数,将两个有符号整数相加,但如果存在正溢出则返回 INT_MAX,如果存在负溢出则返回 INT_MIN。我必须遵循非常严格的操作符限制。所有整数都是二进制补码形式
我有一个 Loan 类,它在其 printPayment 方法中打印硬件分配的贷款摊销表。我们还将实现先打印付款方式和最后打印付款方式。由于我的计算是在 printPayment 方法中完成的,所以我
大家好。我需要帮助来理解我的硬件分配。我刚开始使用 C++,不太了解。我确实知道堆栈和斐波那契数列的基础知识。但是我并不完全理解给我的问题,不需要解决问题的代码,而是帮助澄清一些步骤。这是硬件: “通
作为我的 C++ 硬件的一部分,我必须实现一个通用的 Map 容器。 我应该实现的映射应该有一个迭代器和一个常量迭代器。我决定将数据存储在 map 中的一个节点内 [就像在链表中一样]。 我得到了 m
C/C++ 程序在具有硬件断点功能的调试器下的嵌入式 PowerPC 上运行。在2个文件和2个任务中相应地已知全局变量'char Name [256]'。例如,一项任务读取 Name,另一项任务用文本
我正在阅读 CSAPP 并尝试完成作业问题。假设 w = 32,2.75 是关于通过将两个 32 位无符号整数相乘得到高 32 位。给定函数 int signed_high_prod(int x, i
我正在寻找最官方的来源来完成/维护这个方法: -(NSString*)platformString { NSString *platform = [self platform]; if
我是一名优秀的程序员,十分优秀!