This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('Mars Rover', () => { | |
| [ | |
| {facing: 'N', endsFacing: 'E'}, | |
| {facing: 'E', endsFacing: 'S'}, | |
| {facing: 'S', endsFacing: 'W'}, | |
| {facing: 'W', endsFacing: 'N'} | |
| ].forEach(({facing, endsFacing}) => { | |
| it('turns right from ${facing} to ${endsFacing}', () => { | |
| let rover = {facing: facing}; | |
| rover = exec(rover, 'R'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| IDENTIFICATION DIVISION. | |
| PROGRAM-ID. BASKET-TEST. | |
| DATA DIVISION. | |
| FILE SECTION. | |
| WORKING-STORAGE SECTION. | |
| COPY 'total_params.cpy'. | |
| COPY 'test_context.cpy'. | |
| 01 expected PIC 9(04)V9(2). | |
| PROCEDURE DIVISION. | |
| MAIN-PROCEDURE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| IDENTIFICATION DIVISION. | |
| PROGRAM-ID. SQRT. | |
| DATA DIVISION. | |
| WORKING-STORAGE SECTION. | |
| 01 prev PIC 9(08)V9(12) VALUE ZEROES. | |
| LINKAGE SECTION. | |
| 01 num PIC 9(08)V9(12). | |
| 01 root PIC 9(08)V9(12) VALUE ZEROES. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const assert = require('assert'); | |
| function CD(artist, title, stock) { | |
| this.stock = stock; | |
| this.getStock = function () { | |
| return this.stock; | |
| }; | |
| this.buy = function () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const assert = require('assert'); | |
| function Warehouse(catalogue) { | |
| this.catalogue = catalogue; | |
| this.getCd = function (artist, title) { | |
| return this.catalogue.find((cd) => cd.artist == artist && cd.title == title); | |
| }; | |
| this.buyCd = function (artist, title, catalogue) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const assert = require('assert'); | |
| function Warehouse(catalogue) { | |
| this.catalogue = catalogue; | |
| this.getCd = function (artist, title) { | |
| return this.catalogue.find((cd) => cd.artist == artist && cd.title == title); | |
| } | |
| this.updatedCatalogue = function (cd, boughtCd) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function buyCd(artist, title, catalogue) { | |
| const cd = catalogue.find((cd => cd.artist == artist && cd.title == title)); | |
| return {...catalogue, [catalogue.indexOf(cd)] : {...cd, stock: cd.stock-1}}; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.codemanship.xmastrain; | |
| public class TrainMotion { | |
| private static final int SECONDS_PER_HOUR = 3600; | |
| private static final int METRES_PER_KM = 1000; | |
| private final double acceleration; | |
| private final double topSpeed; | |
| private double velocity; | |
| private double distance; | |
| private final Sensor sensor; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import unittest | |
| from parameterized import parameterized | |
| PAPER = "paper" | |
| SCISSORS = "scissors" | |
| ROCK = "rock" | |
| DRAW = 0 | |
| PLAYER_ONE_WINS = 1 | |
| PLAYER_TWO_WINS = 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Rental(object): | |
| def __init__(self, customer, imdbID, pricer): | |
| self._customer = customer | |
| self._movie = pricer.price(imdbID) | |
| def __str__(self): | |
| return "Movie Rental - customer: " + self._customer \ | |
| + ". Movie => title: " + self._movie.get_title() \ | |
| + ", price: £" + str(self._movie.get_price()) |
NewerOlder