Page 2 of 2 FirstFirst 12
Results 21 to 23 of 23
Like Tree3Likes

Thread: Print Parts Of An Array [User Input]

  1. #21
    Join Date
    Jan 2011
    Posts
    27
    Rep Power
    0

    Default

    Here is the code.

    I still need to brush it up a little but it works.

    Java Code:
    /**
     * Write a description of class Movies here.
     * 
     * @author (your name) 
     * @version (a version number or a date)
     */
    import java.util.Scanner;
    
    public class Movies
    {
        String title;
        String starring;
        String plot;
        int id;
        
        
            
            public Movies (String title, String starring, String plot, int id) {
      
               int getId = id;
                
                Scanner in = new Scanner(System.in); //Looking for user input.
                
                System.out.print("Please enter a number between 1 and 5 for a Movie:  ");
                
                getId = in.nextInt();
                
                System.out.println("\n\nThe Movie you chose was " + title + "\n\n" + "Starring " + starring + "\n\n" + "The Plot of this movie is as follows... \n\n" + plot);
                
                
                    
                
                
            }
            
            
            
        private void setTitle(String title){
                this.title = title;
            }
            
        private void setStarring(String starring){
                this.starring = starring;
            }
            
        private void setPlot(String plot){
                this.plot = plot;
            }
            
        private void setId(int id){
                this.id = id;
            }
            
        private String getTitle(){
                return title;
            }
            
        private String getStarring(){
                return starring;
            }
            
        private String getPlot(){
                return plot;
            }
            
        private int getId(){
                return id;
            }
        
        public static void main (String [] args) {
            
                
                
                Movies commando = new Movies("Commando","Arnold Schwarzenegger","A retired special agent named John Matrix led an elite unit and (has left the armed forces to live in a secluded mountain home \nwith his daughter Jenny. But now he is forced out of retirement when his daughter is kidnapped by \na band of thugs intent on revenge! Unbeknownst to Matrix, the members of his former unit are being \nkilled one by one. Even though Matrix' friend General Franklin Kirby gives Matrix armed guards, \nattackers manage to kidnap Matrix and Jenny. Matrix learns that Bennett, a former member of his \nMatrix' unit who was presumed dead has kidnapped him to try to force Matrix to do a political \nassassination for a man called Arius (who calls himself El Presidente), a warlord formerly bested by \nMatrix who wishes to lead a military coup in his home country. Since Arius will have Jenny killed \nif Matrix refuses, Matrix reluctantly accepts the demand.\n\n", 1);
                Movies predator = new Movies("Predator","Arnold Schwarzenegger","A team of special force ops, led by a tough but fair soldier, Major 'Dutch' Schaefer, \nare ordered in to assist CIA man, George Dillon, on a rescue mission for potential survivors of a \nHelicopter downed over remote South American jungle. Not long after they land, Dutch \nand his team discover that they have been sent in under false pretenses. \nThis deception turns out to be the least of their worries though, when they find \nthemselves being methodically hunted by something not of this world.\n\n", 2);
                Movies terminator = new Movies("The Terminator","Arnold Schwarzenegger","A cyborg is sent from the future on a deadly mission. He has to kill Sarah Connor, a young woman whose life will have a great significance in years to come. Sarah has only one protector - Kyle Reese - also sent from the future. The Terminator uses his exceptional intelligence and strength to find Sarah, but is there any way to stop the seemingly indestructible cyborg ?", 3);
                Movies rambo = new Movies("Rambo","Sylvester Stallone","Vietnam veteran John Rambo has survived many harrowing ordeals in his lifetime and has since withdrawn into a simple and secluded existence in Thailand, where he spends his time capturing snakes for local entertainers, and chauffeuring locals in his old PT boat. Even though he is looking to avoid trouble, trouble has a way of finding him: a group of Christian human rights missionaries, led by Michael Burnett and Sarah Miller, approach Rambo with the desire to rent his boat to travel up the river to Burma. For over fifty years, Burma has been a war zone. The Karen people of the region, who consist of peasants and farmers, have endured brutally oppressive rule from the murderous Burmese military and have been struggling for survival every single day. After some inner contemplation, Rambo accepts the offer and takes Michael, Sarah, and the rest of the missionaries up the river. When the missionaries finally arrive at the Karen village...", 4);
                Movies expendables = new Movies("The Expendables","Sylvester Stallone","Barney Ross leads the 'Expendables', a band of highly skilled mercenaries including knife enthusiast Lee Christmas, martial arts expert Yin Yang, heavy weapons specialist Hale Caesar, demolitionist Toll Road and loose-cannon sniper Gunner Jensen. When the group is commissioned by the mysterious Mr. Church to assassinate the merciless dictator of a small South American island, Barney and Lee head to the remote locale to scout out their opposition. Once there, they meet with local rebel Sandra and discover the true nature of the conflict engulfing the city. When they escape the island and Sandra stays behind, Ross must choose to either walk away and save his own life - or attempt a suicidal rescue mission that might just save his soul.", 5);
                            
                
                
                
                
            }
            
            }

  2. #22
    sibernewf is offline Member
    Join Date
    Mar 2011
    Posts
    48
    Rep Power
    0

    Default

    Congratulations. I would also like to say the first 2 replies were very thorough and excellent, so grats on the posters.
    Just remember when learning start simple, and build on that.

    Well done on solving this one.

    ;-)

  3. #23
    Join Date
    Jan 2011
    Posts
    27
    Rep Power
    0

    Default

    Thanks bro...

    How can I build on this in that if I wanted the font to changem and perhaps have a grey background with a white boarder?

    :)

    Many thanks!! Daz.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. user input array
    By localhost in forum New To Java
    Replies: 5
    Last Post: 12-30-2010, 05:00 AM
  2. Replies: 2
    Last Post: 12-02-2010, 05:18 AM
  3. Read user input into integer array
    By varunb in forum New To Java
    Replies: 12
    Last Post: 07-09-2010, 01:50 PM
  4. how to get input from User
    By Alvaro in forum New To Java
    Replies: 7
    Last Post: 01-16-2010, 12:02 AM
  5. Replies: 5
    Last Post: 11-26-2009, 08:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •