This file contains 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
void snowFall(){ | |
// draw background on canvas | |
ctx.fillStyle="#000"; | |
ctx.fillRect(0,0,W,H); | |
//drawing intitial snowflakes on canvas | |
ctx.fillStyle = "#fff"; | |
// rain | |
ctx.beginPath(); | |
This file contains 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
void main() { | |
var canvas = querySelector('#stage'); | |
ctx = canvas.getContext('2d'); | |
// resize canvas | |
canvas.width = W; | |
canvas.height = H; | |
// create random flakes | |
for(int i = 0; i < maxFlakes; i++){ |
This file contains 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 'dart:io'; | |
final int port = 5000; | |
final String address = "127.0.0.1"; | |
void main() { | |
} |
This file contains 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 'dart:io'; | |
final int port = 5000; | |
final String address = "127.0.0.1"; | |
void main() { | |
HttpServer.bind(address, port) | |
.then((HttpServer server){ | |
}); |
This file contains 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 'dart:io'; | |
final int port = 5000; | |
final String address = "127.0.0.1"; | |
void main() { | |
HttpServer.bind(address, port) | |
.then((HttpServer server){ | |
print('listening for connections on $port'); | |
server.listen((HttpRequest request) { |
This file contains 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 'dart:io'; | |
import 'dart:async'; | |
final int port = 5000; | |
final String address = "127.0.0.1"; | |
void main() { | |
Future<ServerSocket> serverFuture = ServerSocket.bind(address, port); | |
serverFuture.then((ServerSocket server) { | |
print('listening for connections on ' + server.port.toString()); |
This file contains 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 'package:unittest/unittest.dart'; | |
import '../bin/factory_pattern.dart'; | |
void main(){ | |
test("new instance of Shape is created", (){ | |
var shape = new IShape(); | |
expect(shape is IShape, isTrue); | |
}); | |
test("new instance of Rectangle is created", (){ |
This file contains 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 IShape{ | |
void draw(){} | |
} | |
class Rectangle implements IShape{ | |
void draw(){ | |
print("Inside Rectangle::draw() method."); | |
} | |
} |
This file contains 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 ShapeFactory{ | |
IShape getShape(String shapeType){ | |
// check for nulls being passed | |
if(shapeType == null){ | |
return null; | |
} | |
// check for types | |
var type = shapeType.toLowerCase(); | |
switch(type){ |
This file contains 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
void main() { | |
var factory = new ShapeFactory(); | |
var rectangle = factory.getShape('rectangle'); | |
rectangle.draw(); | |
} |