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 React from 'react'; | |
class BadComponent extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
message : this.props.message | |
}; | |
} |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
<style> | |
section { | |
float:left; |
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
// Need to count how many instances have been created of SomeClass | |
public class SomeClass { | |
public static int numberOfInstances = 0; | |
public SomeClass() { | |
numberOfInstances++; | |
} | |
} |
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
public class LargeConsumer { | |
public static void main(String[] args) { | |
new Thread() { | |
@Override | |
public void run() { | |
System.out.println("It Works"); | |
} | |
}.start(); | |
} |
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
public class TotalCalculator { | |
static int price; | |
static boolean isRegisteredUser; | |
static int quantity; | |
public static double getTotal() { | |
double totalPrice = price * quantity; | |
if(isRegisteredUser) { | |
return 0.85 * price * quantity; |
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.thoughtworks.rectangle; | |
public class Rectangle { | |
private int length; | |
private int breadth; | |
public Rectangle(int length, int breadth) { | |
this.length = length; | |
this.breadth = breadth; |
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.thoughtworks.rectangle; | |
public class Rectangle { | |
public int area(int length, int breadth) { | |
return length * breadth; | |
} | |
} |
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 RectangleTest { | |
@Test | |
void areaOfAUnitRectangleShouldBeOne() { | |
Rectangle rectangle = new Rectangle(1, 1); | |
int actualArea = rectangle.area(); | |
int expectedArea = 10; | |
assertEquals(expectedArea, actualArea); | |
} |
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 RectangleTest { | |
@Test | |
void areaOfAUnitRectangleShouldBeOne() { | |
Rectangle rectangle = new Rectangle(1, 1); | |
int actualArea = rectangle.area(); | |
int expectedArea = 1; | |
assertEquals(expectedArea, expectedArea); | |
} |
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
public class Rectangle { | |
private final int length; | |
private final int breadth; | |
public Rectangle(int length, int breadth) { | |
this.length = length; | |
this.breadth = breadth; | |
} |
NewerOlder