1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
bonufazy [111]
3 years ago
12

Write a class named Episode. An instance of this episode class will represent a single episode of a TV show, with a title, a sea

son number, and an episode number. For example "Friends, season 1, episode 1", or "The Wire, season 3, episode 5." Your class should have the following constructors and methods: A constructor that accepts three arguments: a String for the title, an int for the season number, and an int for the episode number. A constructor that accepts only a String, for the title, and sets the season and episode numbers to 1. A setter and getter for the title. (never mind the season and episode numbers.) A method named "equals", that accepts an Episode, and returns true if the title, season number and episode number are the same as the receiving object's. A method named "comesBefore". This method should also accept an Episode. It should return true if the episode that receives the invocation comes before the parameter. That is only true if the two objects have the same title, and if the argument comes from a later season, or the same season, but a later episode. Write only the class. Do not write a whole program
Computers and Technology
1 answer:
gavmur [86]3 years ago
7 0

Answer:

See explaination

Explanation:

class Episode{

//Private variables

private String title;

private int seasonNumber;

private int episodeNumber;

//Argumented constructor

public Episode(String title, int seasonNumber, int episodeNumber) {

this.title = title;

this.seasonNumber = seasonNumber;

this.episodeNumber = episodeNumber;

}

//Getter and setters

public String getTitle() {

return title;

}

public void setTitle(String title) {

this.title = title;

}

public int getSeasonNumber() {

return seasonNumber;

}

public void setSeasonNumber(int seasonNumber) {

this.seasonNumber = seasonNumber;

}

public int getEpisodeNumber() {

return episodeNumber;

}

public void setEpisodeNumber(int episodeNumber) {

this.episodeNumber = episodeNumber;

}

public boolean comesBefore(Episode e){

//Check if titles' match

if(this.title.equals(e.getTitle())){

//Compare season numbers

if(this.seasonNumber<e.seasonNumber){

return true;

}

//Check if season numbers match

else if(this.seasonNumber==e.getSeasonNumber()){

return this.episodeNumber<e.getEpisodeNumber();

}

}

return false;

}

atOverride // replace the at with at symbol

public String toString() {

return title+", season "+seasonNumber+", episode "+episodeNumber;

}

}

class Main{

public static void main(String[] args) {

Episode e = new Episode("Friends",1,1);

System.out.println(e);

Episode e2 = new Episode("The Wire",3,5);

System.out.println(e2);

System.out.println(e.getTitle()+" comes before "+e2.getTitle()+" = "+e.comesBefore(e2));

}

}

You might be interested in
How do I find a space in my String and replace it? JAVA
Fantom [35]

Answer:

This article shows how to use regex to remove spaces in between a String.

A string with spaces in between.

String text = "Hello World Java.";

We want to remove the spaces and display it as below:

Hello World Java.

1. Java regex remove spaces

In Java, we can use regex \\s+ to match whitespace characters, and replaceAll("\\s+", " ") to replace them with a single space.

Regex explanation.

`\\s` # Matches whitespace characters.

+ # One or more

StringRemoveSpaces.java

package com.mkyong.regex.string;

public class StringRemoveSpaces {

public static void main(String[] args) {

String text = "Hello World Java.";

String result = text.replaceAll("\\s+", " ");

System.out.println(result);

}

}

Output

Terminal

Hello World Java.

8 0
3 years ago
A personal computer uses a number of chips mounted on a circuit board called
Vesnalui [34]
The answer is d.mother board 

7 0
3 years ago
E whether True or False.
Natasha_Volkova [10]

Answer:

Learn vocabulary, terms, and more with flashcards, games, and other study ... covers a large geographical area and is made up of many smaller networks. ... you share the cable infrastructure with your neighbors ... do you need if you want to connect two network segments together such as a ... the twists reduce crosstalk.Explanation:

5 0
3 years ago
You have the opportunity to meet some droids and Wookies!
scZoUnD [109]

Answer:

name = input("Enter name: ")

droids = int(input("How many droids you want to meet? "))

wookies = int(input("How many Wookies you want to meet? "))

   

print(name + " wants to meet " + str(droids) + " droids, and " + str(wookies) + " Wookies")

Explanation:

*The code is in Python.

Ask the user to enter the name, number of the droids and number of the Wookies

Print the name, number of the droids, and number of the Wookies

Note that while getting the input for the droids and wookies, you need to typecast the input the int (Since the values are int). Also, to print these variables, you need to typecast them as string in that format.

5 0
3 years ago
Who were the two writers of the screenplay for the 1968 film "2001: A Space Odyssey"?
shusha [124]
Stanley Kubrick & Arthur C. Clarke :)
5 0
3 years ago
Other questions:
  • An office is facing a network issue. The technicians have determined that a virus affected the manager's computer. However, they
    15·1 answer
  • What are the Database used in RDBMS and DBMS<br>please answer immediately​
    10·1 answer
  • Secops focuses on integrating the need for the development team to provide iterative and rapid improvement to system functionali
    14·1 answer
  • Which composer below was not part of the classical period? <br> A. Beethoven B. Bach<br> C. Mozart
    6·1 answer
  • Hi, what’s up, im really bored and have nothing to do
    7·2 answers
  • Write a program that prompts the user to enter a series of numbers between 0 and 10 asintegers. The user will enter all numbers
    6·1 answer
  • Prompts what is a row?
    7·1 answer
  • Example of Not a computer characteristics example
    12·1 answer
  • Is this App for real?​
    5·1 answer
  • Es el conjunto de manifestaciones materiales, intelectuales y espirituales que distinguen a un pueblo a)Civilización b)Cultura c
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!