diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..1e501e3f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +bower_components +node_modules \ No newline at end of file diff --git a/testes/cash-machine/app/controllers/main.js b/testes/cash-machine/app/controllers/main.js new file mode 100644 index 00000000..fcfbc3d4 --- /dev/null +++ b/testes/cash-machine/app/controllers/main.js @@ -0,0 +1,56 @@ +(function(angular, $) { + "use strict"; + + angular.module("cashMachineApp") + .controller("mainController", ["$scope", function($scope) { + var notes = [100, 50, 20, 10]; + var minimunNote = notes[notes.length - 1]; + + $scope.submit = function(e) { + e.preventDefault(); + $scope.errorMessage = ""; + $scope.result = []; + + var value = $scope.value; + + if (!value) { + return; + } + + if (!$.isNumeric(value)) { + $scope.errorMessage = "Not a number"; + return; + } + + if (value < minimunNote) { + $scope.errorMessage = "Must be greater than " + minimunNote; + return; + } + + if (value % minimunNote != 0) { + $scope.errorMessage = "Unavailable Note"; + return; + } + + notes.forEach(function(note) { + var rest = Math.floor(value / note); + + if (rest == 0) { + return; + } + + for (var x = 0; x < rest; x++) { + $scope.result.push({ + value: note + }); + } + + value -= note * rest; + }); + }; + + }]); + + + +})(angular, jQuery); \ No newline at end of file diff --git a/testes/cash-machine/app/module.js b/testes/cash-machine/app/module.js new file mode 100644 index 00000000..d37648c4 --- /dev/null +++ b/testes/cash-machine/app/module.js @@ -0,0 +1,6 @@ +(function(angular) { + "use strict"; + + angular.module("cashMachineApp", ['angular.filter']); + +})(angular); \ No newline at end of file diff --git a/testes/cash-machine/css/custom.css b/testes/cash-machine/css/custom.css new file mode 100644 index 00000000..1360ad27 --- /dev/null +++ b/testes/cash-machine/css/custom.css @@ -0,0 +1,27 @@ +h1{ + text-align: center; +} + +.notes{ + text-align: center; +} + +.notes > div { + display: inline-block; + font-size: 20px; + padding: 20px; + color: green; +} +.notes > div i { + font-size: 30px; + margin-bottom: 5px; + margin-left: 5px; +} + +.notes > div i:last-child { + margin-left: 0; +} + +.notes > div p { + margin: 0; +} diff --git a/testes/cash-machine/index.html b/testes/cash-machine/index.html new file mode 100644 index 00000000..441b0b8f --- /dev/null +++ b/testes/cash-machine/index.html @@ -0,0 +1,60 @@ + + +
+{{note.length}} x {{note[0].value | currency}}
+| Word | +Qty | +
|---|---|
| {{word.word}} | +{{word.qty}} | +