Right now my program says there is an error in line 27 of this code:

Class Netflix:



public class Netflix 
{
private static void main(String[]args) 
{
String comedy, horror, drama, action, genre1;
Movie a = new Movie();
a.setTitle("Avatar");
a.setCast("Sam Worthington");
a.setGenre('a');
a.setYear(2009);
a.setStars(3);
Movie b = new Movie ();
b.setTitle("Battle Los Angeles");
b.setCast("Aaron Eckhart");
b.setGenre('a');
b.setYear(20011);
b.setStars(5);
String stars1;
if (a.setStars(5))
stars1 = "*****";
else if (a.setStars(4))
stars1 = "****";
else if (a.setStars(3))
stars1 = "***";
else if (a.setStars(2))
stars1 = "**";
else if (a.setStars(1))
stars1 = "*";
switch (a.setGenre())

This code contains the main method and needs to display movie info:

Class Movie:



public class Movie {
private String title;
private String cast;
private int year;
private char genre;
private int stars;
public void setStars(int stars)
{
this.stars = stars;
}
public int getStars()
{
return stars;
}
public void setYear(int year)
{
this.year = year;
}
public int getYear()
{
return year;
}
public void setGenre(char genre)
{
this.genre = genre;
}
public char getGenre()
{

Are you going to share the error or is this a guessing game?

I'm not sure what the error is, unfortunately.

The stack trace tells you exactly what the error is. Read it and post it.

The switch statement isn't working.

Where is the stack trace? I haven't learned about it.

JCreator tells me this:

C:\Users\Jessie\Desktop\Netflix.java:24: incompatible types
found   : void
required: boolean
        if (a.setStars(5))
                      ^
C:\Users\Jessie\Desktop\Netflix.java:26: incompatible types
found   : void
required: boolean
        else if (a.setStars(4))
                           ^
C:\Users\Jessie\Desktop\Netflix.java:28: incompatible types
found   : void
required: boolean
        else if (a.setStars(3))
                           ^
C:\Users\Jessie\Desktop\Netflix.java:30: incompatible types
found   : void
required: boolean
        else if (a.setStars(2))
                           ^
C:\Users\Jessie\Desktop\Netflix.java:32: incompatible types
found   : void
required: boolean
        else if (a.setStars(1))
                           ^
C:\Users\Jessie\Desktop\Netflix.java:36: setGenre(char) in Movie cannot be applied to ()
        switch (a.setGenre())
                 ^
C:\Users\Jessie\Desktop\Netflix.java:63: setTitle(java.lang.String) in Movie cannot be applied to ()
        System.out.println(a.setTitle() + a.setyear());
                            ^
C:\Users\Jessie\Desktop\Netflix.java:63: cannot find symbol
symbol  : method setyear()
location: class Movie
        System.out.println(a.setTitle() + a.setyear());
                                           ^
C:\Users\Jessie\Desktop\Netflix.java:64: setCast(java.lang.String) in Movie cannot

Looks to be 9+ errors - not 1.

Read the first. You're trying to evaluate a method that has no return ("void") as a boolean in an if() statement. Did you perhaps mean to see if getStars()==5 ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.