Commits

william gouvea committed 0b9f2c4

Reestruturando projeto-1

  • Participants
  • Parent commits 484155c

Comments (0)

Files changed (14)

File shopping-cart/.gitignore

-pom.xml
-*jar
-lib
-classes

File shopping-cart/README

-# shopping-cart
-
-FIXME: write description
-
-## Usage
-
-FIXME: write
-
-## Installation
-
-FIXME: write
-
-## License
-
-Copyright (C) 2010 FIXME
-
-Distributed under the Eclipse Public License, the same as Clojure.

File shopping-cart/lib/clojure-1.2.0.jar

Binary file removed.

File shopping-cart/lib/clojure-contrib-1.2.0.jar

Binary file removed.

File shopping-cart/lib/commons-codec-1.3.jar

Binary file removed.

File shopping-cart/lib/commons-fileupload-1.2.1.jar

Binary file removed.

File shopping-cart/lib/commons-io-1.4.jar

Binary file removed.

File shopping-cart/lib/compojure-0.3.2.jar

Binary file removed.

File shopping-cart/lib/jetty-6.1.21.jar

Binary file removed.

File shopping-cart/lib/jetty-util-6.1.21.jar

Binary file removed.

File shopping-cart/lib/servlet-api-2.5-20081211.jar

Binary file removed.

File shopping-cart/project.clj

-(defproject shopping-cart "1.0.0-SNAPSHOT"
-  :description "FIXME: write"
-  :dependencies [[org.clojure/clojure "1.2.0"]
-                 [org.clojure/clojure-contrib "1.2.0"]
-                 [compojure "0.3.2"]])
-

File shopping-cart/src/shopping_cart/core.clj

-(ns shopping-cart.core)
-
-(def product-id (ref 0))
-
-(def warehouse (ref {}))
-
-(defn auto-increment-id
-    [ref-id]
-    (dosync
-        (let [old-id @ref-id]
-        (ref-set product-id (inc old-id)))))
-
-(defn reset-auto-id
-    [ref-id]
-    (dosync
-        (ref-set ref-id 0)))
-
-(defstruct product :id  :code  :name  :desc :quantity :price )
-
-(def p1 (struct product (auto-increment-id product-id) 100 "Natura Desodorante" "Perfume" 10 60.00))
-(def p2 (struct product (auto-increment-id product-id) 101 "Ventilador FAET" " Ventilador Pequeno" 100 30.00))
-(def p3 (struct product (auto-increment-id product-id) 102 "Mochila Notebook" "Mochila Esportiva para Transportar Notebooks" 35 180.00))
-(def p4 (struct product (auto-increment-id product-id) 103 "Pragmatic Programmer Book" "Livro Referencia para Programadores " 3 120.00))
-
-
-(defn create-product
-    "Create a new product instance , store in warehouse and return it"
-    [product-id-ref warehouse-ref product-code product-price]
-    (dosync
-      (let [warehouse @warehouse-ref
-            id  (auto-increment-id product-id-ref)
-            code product-code
-            price product-price
-            product (struct product id code "" "" price)]
-       (alter warehouse assoc id product code product))))
-
-
-(def shopping-cart (ref {}))
-
-(def cart-id (ref 0))
-
-;(defstruct shopping-item :prod-ref  :quantity)
-;(defstruct shopping-cart :id :total-quantity :total-value :shopping-items)
-;(defn create-cart
-;    "Create cart and initialize the struct values"
-;    []
-;    (let [shop-cart (struct shopping-cart auto-increment-id(cart-id) 0 0.00 (ref {}))])
-;   shop-cart)
-;
-;create-cart drop-cart add-to-cart remove-from-cart  add-quantity drop-quantity
-;
-
-(defn add-to-cart
-    [cart-ref product-id]
-    (dosync
-      (let [id product-id
-              cart @cart-ref]
-       (alter cart assoc :id product-id :quantity 1))))
-
-
-(defn drop-from-cart
-    [cart-ref product-id]
-    (dosync
-      (let [id product-id
-               cart @cart-ref]
-          (alter cart dissoc :id :quantity))))
-

File shopping-cart/test/shopping_cart/test/core.clj

-(ns shopping-cart.test.core
-  (:use [shopping-cart.core] :reload)
-  (:use [clojure.test]))
-
-(deftest replace-me ;; FIXME: write
-  (is false "No tests have been written."))