Question
how do I fix my code? import java.util.Scanner; public interface TelevisionShow { public double numOfEpisodes(int season); public boolean nameStartsWithThe(); public void printName(); public String sameName(String
how do I fix my code?
import java.util.Scanner; public interface TelevisionShow { public double numOfEpisodes(int season); public boolean nameStartsWithThe(); public void printName(); public String sameName(String user_name); } class RickAndMorty implements TelevisionShow { public double numOfEpisodes(int season) { if (season == 1) { return 11; } else if (season == 2 || season == 3) { return 10; } else return 0; } public boolean nameStartsWithThe() { return false; } public void printName() { System.out.println("RickandMorty"); System.out.println("rick and morty"); } public String sameName(String user_name) { if("rick and morty".contains(user_name.toLowerCase())){ return user_name + " is in the title Rick and Morty"; }else{ return user_name + " is not in the title Rick and Morty"; } } public static void main(String[] args) { RickAndMorty rm = new RickAndMorty(); assert rm.numOfEpisodes(1) != 10; assert rm.sameName("Kate").equals("Kate"); assert rm.nameStartsWithThe(); assert rm.numOfEpisodes(2) == 11; assert rm.numOfEpisodes(3) == 12; assert rm.numOfEpisodes(4) == 13; Scanner scanner = new Scanner(System.in); System.out.println("Enter a name: "); String name = scanner.nextLine(); if("rick and morty".contains(name.toLowerCase())) { assert rm.sameName(name).equals(name + " is in the title Rick and Morty"); }else { assert rm.sameName(name).equals(name + " is not in the title Rick and Morty"); } } }
ERROR IS:
----jGRASP exec: java -ea RickAndMorty Exception in thread "main" java.lang.AssertionError at RickAndMorty.main(TelevisionShow.java:46) jGRASP wedge: exit code for process is 1. jGRASP: operation complete.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started