Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/main/scala/users/BasicUser.scala
Original file line number Diff line number Diff line change
@@ -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)
}
10 changes: 9 additions & 1 deletion src/main/scala/users/ContentCreator.scala
Original file line number Diff line number Diff line change
@@ -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
}
16 changes: 16 additions & 0 deletions src/main/scala/users/GenericUser.scala
Original file line number Diff line number Diff line change
@@ -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)
}
}
8 changes: 6 additions & 2 deletions src/main/scala/users/PremiumUser.scala
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion src/test/scala/app/ITubeTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/users/BasicUserTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/users/PremiumUserTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down