Hector Miuler Malpica Gallegos avatar Hector Miuler Malpica Gallegos committed a8b92b9

primera prueba

Comments (0)

Files changed (9)

+<classpath>
+  <classpathentry output="target/scala-2.9.1/classes" path="src/main/scala" kind="src"></classpathentry>
+  <classpathentry output="target/scala-2.9.1/classes" path="src/main/java" kind="src"></classpathentry>
+  <classpathentry output="target/scala-2.9.1/test-classes" path="src/test/scala" kind="src"></classpathentry>
+  <classpathentry output="target/scala-2.9.1/test-classes" path="src/test/java" kind="src"></classpathentry>
+  <classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"></classpathentry>
+  <classpathentry path="/home/miuler/.ivy2/cache/junit/junit/jars/junit-4.10.jar" kind="lib"></classpathentry>
+  <classpathentry path="/home/miuler/.ivy2/cache/org.hamcrest/hamcrest-core/jars/hamcrest-core-1.1.jar" kind="lib"></classpathentry>
+  <classpathentry path="/home/miuler/.ivy2/cache/org.specs2/specs2_2.9.1/jars/specs2_2.9.1-1.11.jar" kind="lib"></classpathentry>
+  <classpathentry path="/home/miuler/.ivy2/cache/org.specs2/specs2-scalaz-core_2.9.1/jars/specs2-scalaz-core_2.9.1-6.0.1.jar" kind="lib"></classpathentry>
+  <classpathentry path="org.eclipse.jdt.launching.JRE_CONTAINER" kind="con"></classpathentry>
+  <classpathentry path="bin" kind="output"></classpathentry>
+</classpath>
+target
+<projectDescription>
+  <name>Kata Potter</name>
+  <buildSpec>
+    <buildCommand>
+      <name>org.scala-ide.sdt.core.scalabuilder</name>
+    </buildCommand>
+  </buildSpec>
+  <natures>
+    <nature>org.scala-ide.sdt.core.scalanature</nature>
+    <nature>org.eclipse.jdt.core.javanature</nature>
+  </natures>
+</projectDescription>
+name := "Kata Potter"
+
+version := "1.0"
+
+libraryDependencies += "org.specs2" %% "specs2" % "1.12-SNAPSHOT" % "test"
+
+libraryDependencies += "junit" % "junit" % "4.10"	
+
+libraryDependencies += "org.pegdown" % "pegdown" % "1.1.0"
+
+resolvers += Classpaths.typesafeResolver
+
+resolvers ++= Seq("snapshots" at "http://oss.sonatype.org/content/repositories/snapshots",
+                  "releases"  at "http://oss.sonatype.org/content/repositories/releases")
+

project/plugins.sbt

+addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.1.0-RC1")

src/main/java/com/mdp/potter/LibroPotterJ.java

+package com.mdp.potter;
+
+public class LibroPotterJ {
+	
+	private String [] libros;
+}

src/main/scala/com/mdp/potter/LibrosPotter.scala

+package com.mdp.potter
+
+class LibrosPotter {
+  
+  private var libros = Map[Int, Int]()
+  
+  private var canasta7 = 0
+  
+  def libro1 = libros(1)
+  def libro1_= (cantidad:Int):Unit = libros += 1 -> cantidad
+  
+  def libro2 = libros(2)
+  def libro2_= (cantidad:Int):Unit = libros += 2 -> cantidad
+  
+  def libro3 = libros(3)
+  def libro3_= (cantidad:Int):Unit = libros += 3 -> cantidad
+  
+  def libro4 = libros(4)
+  def libro4_= (cantidad:Int):Unit = libros += 4 -> cantidad
+  
+  def libro5 = libros(5)
+  def libro5_= (cantidad:Int):Unit = libros += 5 -> cantidad
+  
+  def libro6 = libros(6)
+  def libro6_= (cantidad:Int):Unit = libros += 6 -> cantidad
+  
+  def libro7 = libros(7)
+  def libro7_= (cantidad:Int):Unit = libros += 7 -> cantidad
+  
+
+  def costo = {
+    var costo = 0
+    for (key <- libros.keys)
+      costo += libros(key) * 8
+    costo
+  }
+  
+  private def llenarCanasta {
+    
+  }
+  
+  private def llenarCanasta7 {
+    if (libros(1) > 0 && libros(2) > 0 && libros(3) > 0 && libros(4) > 0 && libros(5) > 0 && libros(6) > 0 && libros(7) > 0) {
+      canasta7 += 1
+    }
+  }
+  
+  private def llenarCanasta6 {
+    var diferentes = 0
+  }
+  
+}

src/test/scala/com/mdp/potter/HelloWorldSpec.scala

+package com.mdp.potter
+
+import org.junit.runner.RunWith
+import org.specs2.Specification
+import org.specs2.runner.JUnitRunner
+
+
+//@RunWith(classOf[JUnitRunner])
+//class HelloWorldSpec1 extends org.specs2.mutable.Specification {
+//
+//  "The 'Hello worl' string" should {
+//    "contain 11 characters" in {
+//      "Hello world" must have size(11)
+//    }
+//    "start with 'Hello'" in {
+//      "Hello world" must startWith("Hello")
+//    }
+//    "end with 'world'" in {
+//      "Hello world" must endWith("world")
+//    }
+//  }
+//}
+//
+//@RunWith(classOf[JUnitRunner])
+//class HelloWorldSpec2 extends Specification { def is =
+//
+//    "This is a specification to check the 'Hello world' string"                 ^
+//                                                                                p^
+//    "The 'Hello world' string should"                                           ^
+//      "contain 11 characters"                                                   ! e1^
+//      "start with 'Hello'"                                                      ! e2^
+//      "end with 'world'"                                                        ! e3^
+//                                                                                end
+//    
+//    def e1 = "Hello world" must have size(11)
+//    def e2 = "Hello world" must startWith("Hello")
+//    def e3 = "Hello world" must endWith("world")
+//}

src/test/scala/com/mdp/potter/PotterTest.scala

+package com.mdp.potter
+
+import org.junit.runner.RunWith
+import org.specs2.runner.JUnitRunner
+import org.specs2.Specification
+import org.junit.runner.notification.Failure
+
+@RunWith(classOf[JUnitRunner])
+class PotterTest extends Specification { def is = 
+
+  																																							"""
+  Harry Potter es una colección de 7 novelas fantásticas escrita por la
+  autora británica J.K.Rowling, en la que se describen las aventuras del
+  joven aprendiz de mago Harry Potter y sus amigos.															"""^
+  																																							p^
+  																																							"""
+  Nuestra librería ha decidido poner en venta los libros
+  con una oferta especial																												"""^
+  																																							p^
+  	"Cada libro cuesta  8$"																											^
+  		"Libro1 cuesta 8$"																												! e11^
+  		"Libro2 cuesta 8$"																												! e12^
+  		"Libro3 cuesta 8$"																												! e13^
+  																																							p^
+  	"Si compras 2 libros diferentes tienes un 5% de descuento"									^
+  		"Compro libro1 y libro2, debe de costar 15.2"															! e2^
+  																																							p^
+  	"Si compras 3 libros diferentes tienes un 10% de descuento"									! todo^
+  																																							p^
+  	"si compras 4 libros diferentes tienes un 15% de descuento"									! todo^
+  																																							p^
+  	"si compras 5 libros diferentes tienes un 20% de descuento"									! todo^
+  																																							p^
+  	"si compras 6 libros diferentes tienes un 30% de descuento"									! todo^
+  																																							p^
+  	"si compras toda la colección tienes un 45% de descuento"										! todo^
+  																																							end
+
+  def e11 = {
+		val libros = new LibrosPotter
+		libros.libro1 = 1
+		libros.costo must_== 8
+	}
+
+  def e12 = {
+		val libros = new LibrosPotter
+		libros.libro2 = 1
+		libros.costo must_== 8
+	}
+
+  def e13 = {
+		val libros = new LibrosPotter
+		libros.libro3 = 1
+		libros.costo must_== 8
+	}
+
+	def e2 = {
+	  val libros = new LibrosPotter
+	  libros.libro1 = 1
+	  libros.libro2 = 1
+	  libros.costo must_== 15.2
+	}
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.