Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 10 of 10

Thread: Java Program Add boolean method

Threaded View

  1. #1
    Junior Member
    Join Date
    Feb 2018
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java Program Add boolean method

    I need to add a boolean method to add another movie, but want to know the steps to do so. this is my MovieTest
    import java.util.Scanner;
     
    public class MovieTest
    	{
    	public static void main(String[] args)
    	{
    	String testMovie;
    	int testRating;
    	String[] testCharacter = new String[3];
     
    	Scanner keyboard = new Scanner(System.in);
     
    	System.out.print("Enter your favorite movie: ");
    	testMovie = keyboard.nextLine();
     
    	System.out.print("Rate this movie from 1-10: ");
    	testRating = keyboard.nextInt();
     
    	keyboard.nextLine();
    	System.out.print("Who is your favorite character? ");
    	testCharacter[0] = keyboard.nextLine();
     
    	Movie movie = new Movie( testMovie, testRating, testCharacter);
     
    	System.out.println("Favorite movie: " + movie.getFavMovie());
    	System.out.println("Movie Rating: " + movie.getRating());
    	String[] character = movie.getCharacter();
    		for (int index = 0; index < character.length; index++)
    		{
    	  System.out.println("Print Favorite Character" + character[index]) ;
    		}
     
     
    	}


    }

    --- Update ---

    This is my class file
    public class Movie
    {
     //naming fields
     private String favmovie;
     private int movierating;
     private String[] character;
     
     public Movie(String movie, int rating, String[] character)
     {
      this.favmovie = movie;
      this.movierating = rating;
      this.character = character;
     
     }
     
     public void setFavMovie(String movie)
     {
      this.favmovie = movie;
     }
     
     public void setMovieRating(int rating)
     {
      this.movierating = rating;
     }
     
     public void setCharacter(String[] character)
     {
      this.character = character;
     }
     
     public String getFavMovie()
     {
      return this.favmovie;
     }
     
     public int getRating()
     {
      return this.movierating;
     }
     
     public String[] getCharacter()
     {
      return this.character;
     }
    }
    Last edited by ddaniel10; February 8th, 2018 at 09:23 AM.

Similar Threads

  1. Java program to add two numbers
    By Prasanth.likith in forum What's Wrong With My Code?
    Replies: 4
    Last Post: January 31st, 2014, 03:33 AM
  2. My java program won't add up the numbers?
    By meaganicole in forum What's Wrong With My Code?
    Replies: 7
    Last Post: January 5th, 2012, 12:02 PM
  3. Boolean method returning a boolean value
    By Deprogrammer in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 21st, 2010, 10:56 AM
  4. Need help with what I believe is Boolean & add branching
    By JavaBeginner123 in forum What's Wrong With My Code?
    Replies: 12
    Last Post: October 1st, 2010, 01:55 PM
  5. How do you add GUI to this java program?
    By leyla in forum AWT / Java Swing
    Replies: 1
    Last Post: October 18th, 2009, 01:32 PM

Tags for this Thread