diff --git a/src/main/scala/users/BasicUser.scala b/src/main/scala/users/BasicUser.scala index bdc0690..d9e33a5 100644 --- a/src/main/scala/users/BasicUser.scala +++ b/src/main/scala/users/BasicUser.scala @@ -1,5 +1,10 @@ package users +import scala.collection.mutable.ArrayBuffer -class BasicUser { +class BasicUser(name: String) extends GenericUser(name) { + private val subscriptions: ArrayBuffer[Account] = ArrayBuffer[Account]() + + def getSubscriptions: ArrayBuffer[Account]=subscriptions + def subscribeTo(contentCreator: ContentCreator):Unit=contentCreator.subscribeTo(this) } diff --git a/src/main/scala/users/ContentCreator.scala b/src/main/scala/users/ContentCreator.scala index bef197c..4cd76c4 100644 --- a/src/main/scala/users/ContentCreator.scala +++ b/src/main/scala/users/ContentCreator.scala @@ -1,5 +1,13 @@ package users +import videos.Video +import app.ITube +import scala.collection.mutable.ArrayBuffer -class ContentCreator { +class ContentCreator(username: String) extends GenericUser(username){ + private val subscribers: ArrayBuffer[Account] = ArrayBuffer[Account]() + def uploadVideo(video: Video, app: ITube):Unit = app.addVideo(video) + def deleteVideo(video: Video, app: ITube):Unit = app.deleteVideo(video) + def getSubscribers: ArrayBuffer[Account] = subscribers + def subscribeTo(user: Account): Unit = subscribers+=user } diff --git a/src/main/scala/users/GenericUser.scala b/src/main/scala/users/GenericUser.scala new file mode 100644 index 0000000..f98d308 --- /dev/null +++ b/src/main/scala/users/GenericUser.scala @@ -0,0 +1,16 @@ +package users +import videos.Video + +abstract class GenericUser(val username: String) extends Account{ + def getUsername: String ={ + username + } + + def writeComment(video: Video, comment: String): Unit ={ + video.addComment(this,comment) + } + + def likeVideo(video: Video): Unit = { + video.like(this) + } +} diff --git a/src/main/scala/users/PremiumUser.scala b/src/main/scala/users/PremiumUser.scala index 00bbca3..8ac5325 100644 --- a/src/main/scala/users/PremiumUser.scala +++ b/src/main/scala/users/PremiumUser.scala @@ -1,5 +1,9 @@ package users +import videos.Video +import scala.collection.mutable.ArrayBuffer -class PremiumUser { - +class PremiumUser(username: String) extends BasicUser(username) { + private val downloadedVideos: ArrayBuffer[Video] = ArrayBuffer[Video]() + def getDownloadedVideos:ArrayBuffer[Video]=downloadedVideos + def downloadVideo(video: Video):Unit=downloadedVideos+=video } diff --git a/src/test/scala/app/ITubeTest.scala b/src/test/scala/app/ITubeTest.scala index 96eacb4..ce0727b 100644 --- a/src/test/scala/app/ITubeTest.scala +++ b/src/test/scala/app/ITubeTest.scala @@ -13,7 +13,7 @@ class ITubeTest extends FunSuite { var app: ITube = _ override def beforeEach(context: BeforeEach): Unit = { - user = new ContentCreator + user = new ContentCreator("ElRichMC") video = new Video(user) app = new ITube } diff --git a/src/test/scala/users/BasicUserTest.scala b/src/test/scala/users/BasicUserTest.scala index ef32564..9b8bbaf 100644 --- a/src/test/scala/users/BasicUserTest.scala +++ b/src/test/scala/users/BasicUserTest.scala @@ -11,7 +11,7 @@ class BasicUserTest extends FunSuite { override def beforeEach(context: BeforeEach): Unit = { user = new BasicUser("username") - creator = new ContentCreator + creator = new ContentCreator("ElRichMC") video = new Video(creator) } diff --git a/src/test/scala/users/PremiumUserTest.scala b/src/test/scala/users/PremiumUserTest.scala index e8eb10a..6381699 100644 --- a/src/test/scala/users/PremiumUserTest.scala +++ b/src/test/scala/users/PremiumUserTest.scala @@ -11,7 +11,7 @@ class PremiumUserTest extends FunSuite { override def beforeEach(context: BeforeEach): Unit = { user = new PremiumUser("username") - creator = new ContentCreator + creator = new ContentCreator("username") video = new Video(creator) }