首页 > 其他分享 >CS61B_project_gold

CS61B_project_gold

时间:2023-05-13 16:24:03浏览次数:48  
标签:log gold testArray CS61B project addLast addFirst stdArray addNumber

题目描述

 

 1 import static org.junit.Assert.*;
 2 import org.junit.Test;
 3 
 4 public class TestArrayDequeGold {
 5     @Test
 6     public void testStudentArrayDeque() {
 7         StudentArrayDeque<Integer> testArray = new StudentArrayDeque<>();
 8         ArrayDequeSolution<Integer> stdArray = new ArrayDequeSolution<>();
 9         String log = "";
10         for (int i = 0; i < 1000; i++) {
11             if (stdArray.size() == 0) {
12                 int addNumber = StdRandom.uniform(1000);
13                 int headOrBack = StdRandom.uniform(2);
14                 if (headOrBack == 0) {
15                     log = log + "addFirst(" + addNumber + ")\n";
16                     testArray.addFirst(addNumber);
17                     stdArray.addFirst(addNumber);
18                 } else {
19                     log = log + "addLast(" + addNumber + ")\n";
20                     testArray.addLast(addNumber);
21                     stdArray.addLast(addNumber);
22                 }
23             } else {
24                 int x = StdRandom.uniform(4);
25                 int addNumber = StdRandom.uniform(1000);
26                 Integer testremoveNumber = 1;
27                 Integer stdremoveNumber = 1;
28                 switch (x) {
29                     case 0:
30                         log = log + "addFirst(" + addNumber + ")\n";
31                         testArray.addFirst(addNumber);
32                         stdArray.addFirst(addNumber);
33                         break;
34                     case 1:
35                         log = log + "addLast(" + addNumber + ")\n";
36                         testArray.addLast(addNumber);
37                         stdArray.addLast(addNumber);
38                         break;
39                     case 2:
40                         log = log + "removeFirst()\n";
41                         testremoveNumber = testArray.removeFirst();
42                         stdremoveNumber = stdArray.removeFirst();
43                         break;
44                     case 3:
45                         log = log + "removeLast()\n";
46                         testremoveNumber = testArray.removeLast();
47                         stdremoveNumber = stdArray.removeLast();
48                         break;
49                     default:
50                 }
51                 assertEquals(log, stdremoveNumber, testremoveNumber);
52             }
53         }
54 
55     }
56 }

 

标签:log,gold,testArray,CS61B,project,addLast,addFirst,stdArray,addNumber
From: https://www.cnblogs.com/xuenima/p/17397581.html

相关文章

  • Eclipse won't launch because `reload maven project has encountered a proble m`
    关于eclipse因为maven无法启动的问题,参考以下两个网页http://www.91linux.com/html/2016/eclipse_1018/15540.htmlhttp://stackoverflow.com/questions/31080665/eclipse-wont-launch-because-reload-maven-project-has-encountered-a-proble-m不需要删除整个.metadata如果删除......
  • Building wheel for opencv-python (pyproject.toml) ,安装命令增加 --verbose 参数
    Mac安装paddlehub出现Buildingwheelsforcollectedpackages:opencv-python,ffmpy,jieba,seqeval,futureBuildingwheelforopencv-python(pyproject.toml)...解决方法pipinstallopencv-python-ihttps://pypi.tuna.tsinghua.edu.cn/simple--verbose......
  • CS61B_discussion3_week2_2
    1publicclassHorse{2Horsesame;3Stringjimmy;45publicHorse(Stringlee){6jimmy=lee;7}89publicHorsesame(Horsehorse){10if(same!=null){11Horsesame=horse;12......
  • project中资源自动调配顺序
    1、优先级为1000的任务优先使用资源。2、根据任务的限制类别决定。3、关键路径上的任务比非关键路径上的任务优先使用资源。4、优先级高的任务比优先级低的任务优先使用资源。5、比较长的路径上的任务优先使用资源。6、开始时间早的任务优先使用资源。7、工期比较长的任务优先使用......
  • OpenProject:Ubuntu18.04下安装配置(docker方式)
    年前刚跳槽,发现很久没有更新文章啦。最近几年转到了技术管理岗,中小公司的技术管理,免不了做一些PM的活。以前用微软的Project(虽然盗版但真的好用),现在公司不允许使用盗版,只能找找开源的,于是发现了OpenProject。官方提供了几种安装方式:1.Package2.Docker3.UCS4.Other1.尝试下......
  • CS61B_值得注意的知识
    1.GoldenRuleofEquals Forprimitives,theline inty=x copiesthebitsinsidethe x boxintothe y box.Forreferencetypes,wedotheexactsamething.Intheline WalrusnewWalrus=oldWalrus;,wecopythe64bitaddressinthe oldWalrus boxi......
  • CS61B_lab02
    题目描述:dcatenate(IntListA,IntListB):返回一个由A的所有元素组成的列表,后面是B的所有元素。可能会修改A。Don'tuse'new'。publicstaticIntListdcatenate(IntListA,IntListB){if(A==null){returnB;}IntListptr=......
  • Oracle GoldenGate Free 安装
    一些预备安装了docker网络可以连接容器仓库(oracle的)包含oracle账户运行拉取docker镜像dockerpullcontainer-registry.oracle.com/goldengate/goldengate-free:21.9.0.0-oracle启动version:'3'services:app:image:c......
  • No service of type Factory<LoggingManagerInternal> available in ProjectScopeServ
    最近从GitHub上down下来一个项目,却在导入到AS的时候一直报Error:NoserviceoftypeFactory<LoggingManagerInternal>availableinProjectScopeServices.这个错误clean一下项目之后,报出了详细错误信息接下来仔细看异常信息,Couldnotcreatepluginoftype'AndroidMavenPlugin......
  • The Org2Blog Project README.org
    AboutBlogfromOrgmodetoWordPress.TableofContentsAboutTableofContentsRequirementsAndCompatibilityInstallationUsingAPackageUse-PackageInstallThePackageYourselfBuildThePackageYourselfSettingUpTheSourceCodeByHandUsag......