当前位置: 首页 > news >正文

瀑布式网站公司宣传册怎么设计

瀑布式网站,公司宣传册怎么设计,看片,wordpress 添加用户组编程kata是一种练习#xff0c;可以帮助程序员通过练习和重复练习来磨练自己的技能。 本文是“ 通过Katas进行Java教程 ”系列的一部分。 本文假定读者已经具有Java的经验#xff0c;熟悉单元测试的基础知识#xff0c;并且知道如何从他最喜欢的IDE#xff08;我是Intell… 编程kata是一种练习可以帮助程序员通过练习和重复练习来磨练自己的技能。 本文是“ 通过Katas进行Java教程 ”系列的一部分。 本文假定读者已经具有Java的经验熟悉单元测试的基础知识并且知道如何从他最喜欢的IDE我是IntelliJ IDEA 运行它们。 下面显示证明解决方案正确的测试。 解决此问题的推荐方法是使用测试驱动的开发方法编写第一个测试的实现确认它通过并转到下一个测试。 一旦所有测试通过就可以认为解决了问题。 有关最佳做法的更多信息请阅读“ 测试驱动开发TDD使用Java范例的最佳做法” 。 测试下方提供了一种可能的解决方案。 尝试先自己解决kata。 火星漫游者 开发一个可在网格上移动漫游车的API。 规则 您将获得流动站的初始起点xy及其面向的方向NSEW。 流动站接收命令的字符数组。 实施使漫游车前进/后退fb的命令。 实现使流动站左/右lr旋转的命令。 实现从网格的一个边缘到另一边缘的环绕。 行星毕竟是球体 每次移动到新的广场之前请执行障碍检测。 如果给定的命令序列遇到障碍物则流动站将移动到最后一个可能的点并报告障碍物。 测验 以下是一组可用于以TDD方式解决此问题的单元测试。 package com.technologyconversations.kata.marsrover;import org.junit.Before; import org.junit.Test;import java.util.ArrayList; import java.util.Arrays; import java.util.List;import static org.assertj.core.api.Assertions.*;/* Source: http://dallashackclub.com/roverDevelop an api that moves a rover around on a grid. * You are given the initial starting point (x,y) of a rover and the direction (N,S,E,W) it is facing. * - The rover receives a character array of commands. * - Implement commands that move the rover forward/backward (f,b). * - Implement commands that turn the rover left/right (l,r). * - Implement wrapping from one edge of the grid to another. (planets are spheres after all) * - Implement obstacle detection before each move to a new square. * If a given sequence of commands encounters an obstacle, the rover moves up to the last possible point and reports the obstacle. */ public class RoverSpec {private Rover rover;private Coordinates roverCoordinates;private final Direction direction Direction.NORTH;private Point x;private Point y;private ListObstacle obstacles;Beforepublic void beforeRoverTest() {x new Point(1, 9);y new Point(2, 9);obstacles new ArrayListObstacle();roverCoordinates new Coordinates(x, y, direction, obstacles);rover new Rover(roverCoordinates);}Testpublic void newInstanceShouldSetRoverCoordinatesAndDirection() {assertThat(rover.getCoordinates()).isEqualToComparingFieldByField(roverCoordinates);}Testpublic void receiveSingleCommandShouldMoveForwardWhenCommandIsF() throws Exception {int expected y.getLocation() 1;rover.receiveSingleCommand(F);assertThat(rover.getCoordinates().getY().getLocation()).isEqualTo(expected);}Testpublic void receiveSingleCommandShouldMoveBackwardWhenCommandIsB() throws Exception {int expected y.getLocation() - 1;rover.receiveSingleCommand(B);assertThat(rover.getCoordinates().getY().getLocation()).isEqualTo(expected);}Testpublic void receiveSingleCommandShouldTurnLeftWhenCommandIsL() throws Exception {rover.receiveSingleCommand(L);assertThat(rover.getCoordinates().getDirection()).isEqualTo(Direction.WEST);}Testpublic void receiveSingleCommandShouldTurnRightWhenCommandIsR() throws Exception {rover.receiveSingleCommand(R);assertThat(rover.getCoordinates().getDirection()).isEqualTo(Direction.EAST);}Testpublic void receiveSingleCommandShouldIgnoreCase() throws Exception {rover.receiveSingleCommand(r);assertThat(rover.getCoordinates().getDirection()).isEqualTo(Direction.EAST);}Test(expected Exception.class)public void receiveSingleCommandShouldThrowExceptionWhenCommandIsUnknown() throws Exception {rover.receiveSingleCommand(X);}Testpublic void receiveCommandsShouldBeAbleToReceiveMultipleCommands() throws Exception {int expected x.getLocation() 1;rover.receiveCommands(RFR);assertThat(rover.getCoordinates().getX().getLocation()).isEqualTo(expected);assertThat(rover.getCoordinates().getDirection()).isEqualTo(Direction.SOUTH);}Testpublic void receiveCommandShouldWhatFromOneEdgeOfTheGridToAnother() throws Exception {int expected x.getMaxLocation() x.getLocation() - 2;rover.receiveCommands(LFFF);assertThat(rover.getCoordinates().getX().getLocation()).isEqualTo(expected);}Testpublic void receiveCommandsShouldStopWhenObstacleIsFound() throws Exception {int expected x.getLocation() 1;rover.getCoordinates().setObstacles(Arrays.asList(new Obstacle(expected 1, y.getLocation())));rover.getCoordinates().setDirection(Direction.EAST);rover.receiveCommands(FFFRF);assertThat(rover.getCoordinates().getX().getLocation()).isEqualTo(expected);assertThat(rover.getCoordinates().getDirection()).isEqualTo(Direction.EAST);}Testpublic void positionShouldReturnXYAndDirection() throws Exception {rover.receiveCommands(LFFFRFF);assertThat(rover.getPosition()).isEqualTo(8 X 4 N);}Testpublic void positionShouldReturnNokWhenObstacleIsFound() throws Exception {rover.getCoordinates().setObstacles(Arrays.asList(new Obstacle(x.getLocation() 1, y.getLocation())));rover.getCoordinates().setDirection(Direction.EAST);rover.receiveCommands(F);assertThat(rover.getPosition()).endsWith( NOK);}} 以下是一种可能的解决方案。 package com.technologyconversations.kata.marsrover;/* Method receiveCommands should be used to transmit commands to the rover.*/ public class Rover {private Coordinates coordinates;public void setCoordinates(Coordinates value) {coordinates value;}public Coordinates getCoordinates() {return coordinates;}public Rover(Coordinates coordinatesValue) {setCoordinates(coordinatesValue);}public void receiveCommands(String commands) throws Exception {for (char command : commands.toCharArray()) {if (!receiveSingleCommand(command)) {break;}}}public boolean receiveSingleCommand(char command) throws Exception {switch(Character.toUpperCase(command)) {case F:return getCoordinates().moveForward();case B:return getCoordinates().moveBackward();case L:getCoordinates().changeDirectionLeft();return true;case R:getCoordinates().changeDirectionRight();return true;default:throw new Exception(Command command is unknown.);}}public String getPosition() {return getCoordinates().toString();}} 完整源代码位于GitHub存储库[https://github.com/vfarcic/mars-rover-kata-java中。 上面的代码仅表示主类的代码。 还有其他几个类/对象及其相应的规范。 除了测试和实现之外存储库还包括build.gradle可用于下载AssertJ依赖项并运行测试README.md包含有关如何设置项目的简短说明。 您有什么解决方案 将其发布为评论以便我们可以比较解决此kata的不同方法。 翻译自: https://www.javacodegeeks.com/2014/10/java-tutorial-through-katas-mars-rover.html
http://wiki.neutronadmin.com/news/324754/

相关文章:

  • 微商货源网站源码济南seo官网优化
  • 建设一个功能简单的网站一个做品牌零食特卖的网站
  • 新乡网站建设服务制作网站深圳
  • 建设银行网站会员用户名格式网站建设费会计科目
  • 贞丰县建设局网站网站查询 工信部
  • 零基础建设网站教程wordpress 别名一致
  • 网站分析软件公寓注册公司需要什么条件
  • 住房与城乡建设部网站EPC一个网站的优化怎么做
  • 出口网站建设方案微网站什么意思
  • 手机如何制作网站西安免费建网站设计
  • 工业信息化部网站备案查询中国建设银行人才招聘官方网站
  • 大学生做爰网站江苏和住房建设厅网站
  • 推广比较好的网站有哪些手机网页无法打开是什么原因
  • 一个网站需要几个人做软文投放平台有哪些
  • 网站建设所需素材ps软件下载安装
  • 做seo怎么设计网站觅知网是免费的吗
  • 网站建设要求 优帮云wordpress产品分类
  • 越秀网站建设价格做机械的有什么网站
  • 集团网站建设工作方案怎么用网站推广
  • 成都网站建设推广服务百度导航
  • 国内有做外汇的正规网站吗龙岩做网站开发哪家公司好
  • 建了一个网站 如何找到放图片的文件夹阿里云购买网站登录
  • php 企业网站开发实例萝岗手机网站建设
  • 网站的规划与设计郑州天道做网站
  • 如何对上传的网站做代码修改建网站用什么系统好
  • 高端企业网站公司宠物医院网站建设方案
  • 抚顺网站建设公司果业局网站建设
  • 企业门户网站建设公司广西网站建设教程
  • 反钓鱼网站建设期查看公司股票的网站
  • 建网站都要什么费用滁州哪里做网站