wwzeng1 / scala-examples

Scala code examples
0 stars 0 forks source link

Sweep: add 10 more example animals to src/main/scala/FBoundedPolymorphism.scala #1

Open wwzeng1 opened 2 weeks ago

wwzeng1 commented 2 weeks ago

do each of the 10 animals in a separate code_change


Add 10 new animal examples to FBoundedPolymorphism.scala

Description:

Extend the FBoundedPolymorphism.scala file with 10 additional animal examples to demonstrate F-Bounded Polymorphism.

Tasks:

  1. In src/main/scala/FBoundedPolymorphism.scala, add the following new animal classes:
class Lion extends Animal[Lion] {
  override def breed: List[Animal[Lion]] = ???
}
  1. In src/main/scala/FBoundedPolymorphism.scala, add:
class Tiger extends Animal[Tiger] {
  override def breed: List[Animal[Tiger]] = ???
}
  1. In src/main/scala/FBoundedPolymorphism.scala, add:
class Elephant extends Animal[Elephant] {
  override def breed: List[Animal[Elephant]] = ???
}
  1. In src/main/scala/FBoundedPolymorphism.scala, add:
class Giraffe extends Animal[Giraffe] {
  override def breed: List[Animal[Giraffe]] = ???
}
  1. In src/main/scala/FBoundedPolymorphism.scala, add:
class Penguin extends Animal[Penguin] {
  override def breed: List[Animal[Penguin]] = ???
}
  1. In src/main/scala/FBoundedPolymorphism.scala, add:
class Kangaroo extends Animal[Kangaroo] {
  override def breed: List[Animal[Kangaroo]] = ???
}
  1. In src/main/scala/FBoundedPolymorphism.scala, add:
class Dolphin extends Animal[Dolphin] {
  override def breed: List[Animal[Dolphin]] = ???
}
  1. In src/main/scala/FBoundedPolymorphism.scala, add:
class Eagle extends Animal[Eagle] {
  override def breed: List[Animal[Eagle]] = ???
}
  1. In src/main/scala/FBoundedPolymorphism.scala, add:
class Panda extends Animal[Panda] {
  override def breed: List[Animal[Panda]] = ???
}
  1. In src/main/scala/FBoundedPolymorphism.scala, add:
class Gorilla extends Animal[Gorilla] {
  override def breed: List[Animal[Gorilla]] = ???
}
sweep-nightly[bot] commented 2 weeks ago

🚀 Here's the PR! #2

Sweeping

Search Results

Response

  1. Let's add the Lion class:

src/main/scala/FBoundedPolymorphism.scala

--- 
+++ 
@@ -1,5 +1,8 @@
   class Crocodile extends Animal[Crocodile] {
     override def breed: List[Animal[Crocodile]] = ???
+  }
+  class Lion extends Animal[Lion] {
+    override def breed: List[Animal[Lion]] = ???
   }
   trait Entity[E <: Entity[E]] //ORM
   class Person extends Comparable[Person] { //FBP
  1. Now, let's add the Tiger class:

src/main/scala/FBoundedPolymorphism.scala

--- 
+++ 
@@ -1,5 +1,8 @@
   class Lion extends Animal[Lion] {
     override def breed: List[Animal[Lion]] = ???
+  }
+  class Tiger extends Animal[Tiger] {
+    override def breed: List[Animal[Tiger]] = ???
   }
   trait Entity[E <: Entity[E]] //ORM
   class Person extends Comparable[Person] { //FBP
  1. Let's add the Elephant class:

src/main/scala/FBoundedPolymorphism.scala

--- 
+++ 
@@ -1,5 +1,8 @@
   class Tiger extends Animal[Tiger] {
     override def breed: List[Animal[Tiger]] = ???
+  }
+  class Elephant extends Animal[Elephant] {
+    override def breed: List[Animal[Elephant]] = ???
   }
   trait Entity[E <: Entity[E]] //ORM
   class Person extends Comparable[Person] { //FBP
  1. Now, let's add the Giraffe class:

src/main/scala/FBoundedPolymorphism.scala

--- 
+++ 
@@ -1,5 +1,8 @@
   class Elephant extends Animal[Elephant] {
     override def breed: List[Animal[Elephant]] = ???
+  }
+  class Giraffe extends Animal[Giraffe] {
+    override def breed: List[Animal[Giraffe]] = ???
   }
   trait Entity[E <: Entity[E]] //ORM
   class Person extends Comparable[Person] { //FBP
  1. Let's add the Penguin class:

src/main/scala/FBoundedPolymorphism.scala

--- 
+++ 
@@ -1,5 +1,8 @@
   class Giraffe extends Animal[Giraffe] {
     override def breed: List[Animal[Giraffe]] = ???
+  }
+  class Penguin extends Animal[Penguin] {
+    override def breed: List[Animal[Penguin]] = ???
   }
   trait Entity[E <: Entity[E]] //ORM
   class Person extends Comparable[Person] { //FBP
  1. Now, let's add the Kangaroo class:

src/main/scala/FBoundedPolymorphism.scala

--- 
+++ 
@@ -1,5 +1,8 @@
   class Penguin extends Animal[Penguin] {
     override def breed: List[Animal[Penguin]] = ???
+  }
+  class Kangaroo extends Animal[Kangaroo] {
+    override def breed: List[Animal[Kangaroo]] = ???
   }
   trait Entity[E <: Entity[E]] //ORM
   class Person extends Comparable[Person] { //FBP
  1. Let's add the Dolphin class:

src/main/scala/FBoundedPolymorphism.scala

--- 
+++ 
@@ -1,5 +1,8 @@
   class Kangaroo extends Animal[Kangaroo] {
     override def breed: List[Animal[Kangaroo]] = ???
+  }
+  class Dolphin extends Animal[Dolphin] {
+    override def breed: List[Animal[Dolphin]] = ???
   }
   trait Entity[E <: Entity[E]] //ORM
   class Person extends Comparable[Person] { //FBP
  1. Now, let's add the Eagle class:

src/main/scala/FBoundedPolymorphism.scala

--- 
+++ 
@@ -1,5 +1,8 @@
   class Dolphin extends Animal[Dolphin] {
     override def breed: List[Animal[Dolphin]] = ???
+  }
+  class Eagle extends Animal[Eagle] {
+    override def breed: List[Animal[Eagle]] = ???
   }
   trait Entity[E <: Entity[E]] //ORM
   class Person extends Comparable[Person] { //FBP
  1. Let's add the Panda class:

src/main/scala/FBoundedPolymorphism.scala

--- 
+++ 
@@ -1,5 +1,8 @@
   class Eagle extends Animal[Eagle] {
     override def breed: List[Animal[Eagle]] = ???
+  }
+  class Panda extends Animal[Panda] {
+    override def breed: List[Animal[Panda]] = ???
   }
   trait Entity[E <: Entity[E]] //ORM
   class Person extends Comparable[Person] { //FBP
  1. Finally, let's add the Gorilla class:

src/main/scala/FBoundedPolymorphism.scala

--- 
+++ 
@@ -1,5 +1,8 @@
   class Panda extends Animal[Panda] {
     override def breed: List[Animal[Panda]] = ???
+  }
+  class Gorilla extends Animal[Gorilla] {
+    override def breed: List[Animal[Gorilla]] = ???
   }
   trait Entity[E <: Entity[E]] //ORM
   class Person extends Comparable[Person] { //FBP

These changes have added 10 new animal examples to the FBoundedPolymorphism.scala file, each demonstrating the use of F-Bounded Polymorphism. The new classes are Lion, Tiger, Elephant, Giraffe, Penguin, Kangaroo, Dolphin, Eagle, Panda, and Gorilla. Each class extends the Animal trait with its own type as the type parameter, following the existing pattern in the file.

Continue the conversation with Sweep here: http://localhost:3000/c/93e95ac7-e43d-41e7-86a2-99a12bbc7c27.

:book: For more information on how to use Sweep, please read our documentation.

Tracking ID: ed1cd7c40e