This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import webbrowser | |
| class Movie(): | |
| def __init__(self, movies_title, movie_storyline, poster_image, | |
| trailer_youtube): | |
| self.title = movies_title | |
| self.story_line = movie_storyline | |
| self.poster_image_url = poster_image | |
| self.trailer_youtube_url = trailer_youtube |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import webbrowser | |
| import os | |
| import re | |
| # Styles and scripting for the page | |
| main_page_head = ''' | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Fresh Tomatoes!</title> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # THINGS A class Movie should HAVE! | |
| # 1. title | |
| # 2. storyline | |
| # 3. poster_image | |
| # 4.youtube_trailer | |
| # B, Things a movie should do | |
| # -show_trailer() | |
| from main import open_movies_page | |
| import media | |
| toy_story = media.Movie("Toy Story", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data class Theatre(val street:String, val name:String, val capacity:Int) | |
| data class Movie(val title:String,val ratings:Double,val poster:Image){ | |
| fun bookTicket(theatre: Theatre){ | |
| println("Get a ticket!") | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun bind(artist:Artist)= with(itemView){ | |
| name.text=artist.name | |
| birthday.text=artist.birthday | |
| topBadge.visibility=if(artist.isPopular) View.VISIBLE else View.GONE | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data class Artist(val name:String,val birthday:String,val songs:List<Song>){ | |
| val isPopular by lazy { | |
| (songs.sumByDouble { it.ratings } / songs.size) > 5.0 | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data class Song(val name:String, val ratings:Double) | |
| data class Artist(val name:String,val birthday:String,val songs:List<Song>) | |
| class BadAdapter(context:Context): RecyclerView.Adapter<BadAdapter.ArtistViewHolder>(){ | |
| val inflater=LayoutInflater.from(context)!! | |
| var data= mutableListOf<Artist>() | |
| set(value) { | |
| field=value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class NiceActivity:AppCompatActivity(),Contract.View{ | |
| @Inject lateinit var presenter:Presenter //inject the presenter | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_media) | |
| presenter.start() | |
| } | |
| override fun show(data:List<User>){/* Show the result */} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class NormalActivity:AppCompatActivity(){ | |
| private lateinit var repository:Repository //you can have this injected | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) | |
| /* | |
| * Initialize the repository | |
| */ | |
| repository.fetchData(this::onSuccess,this::onError) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BadActivity:AppCompatActivity(){ | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_media) | |
| loadUsers() //assume configuration changes don't happen in this activity | |
| } | |
| fun loadData(){ | |
| object:AsyncTask<Void,Void, List<User>>(){ | |
| override fun doInBackground(vararg params: Void?): List<User> { |
NewerOlder