[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 178
  • Last Modified:

Creating a Class

1. Create a class Actor. An actor should have firstname, lastname, and a list of movies the actor played. The movie list must have at least one movie. An actor may be used to specify actors and actresses.
2. Create a class Movie. A movie should have a title, a director, a list of
   actors/actresses, and the year of release.
3. Write a Java application called Oscar that
   - prompts the user to nominate 2 actors/actresses with their best movies,
   - prompts the user to nominate 3 best ever moviews from Hollywood,
   - finally prints out a summary list in the following format:
    Nominated actors/actresses:
     1) Clint Eastwood: Million Dollar Baby (2005)
  2) Harrison Ford: Star Wars (1827)
    Nominated movies:
                a) The Day Before Yesterday (1950)
                b) The Day After Tomorrow (2004)
                c) 2001 (1981)  
 
How would I use JOptionPane.showInputDialog(...) to get input from the user for both Actor and Movie objects.



This is what I have so far.....

******************************
package week002;

public class Actor {
  public String name;
  public Movie movie;

  public Actor(String n, Movie m) {
    name = n;
    movie = m;
  }
  public static void main(String[] args) {
    Movie m = new Movie("Indiana Jones", 1990);
    Actor a = new Actor("Harrison Ford", m);
    System.out.println( a.name);
    System.out.println( "Title: " + m.title
                        + "(" + m.year + ")" );
  }

}
*********************************************

package week002;

public class Movie {
  public String title, studio;
  public int year, profit;
  public Actor a;

  public Movie(String t, int year) {
    title=t;
    this.year=year;
  }

}
******************************************

any idea?
0
duemes
Asked:
duemes
1 Solution
 
bloodredsunCommented:
What assignment is this?

Your actor class needs to have different properties: String firstname, String lastname and a list, e.g. ArrayList,  of movies not just one.

Your movie class needs: String title, String director, a list, e.g. ArrayList,  of actors and int releaseYear
0
 
TimYatesCommented:
surely you want a List of movies in each Actor, and a List of Actors in each movie
0
 
sudhakar_koundinyaCommented:

>> How would I use JOptionPane.showInputDialog

here are some examples

// Modal dialog with OK button
    String message = "Line1\nLine2";
    JOptionPane.showMessageDialog(frame, message);
   
    // Modal dialog with yes/no button
    int answer = JOptionPane.showConfirmDialog(frame, message);
    if (answer == JOptionPane.YES_OPTION) {
        // User clicked YES.
    } else if (answer == JOptionPane.NO_OPTION) {
        // User clicked NO.
    }
   
    // Modal dialog with OK/cancel and a text field
    String text = JOptionPane.showInputDialog(frame, message);
    if (text == null) {
        // User clicked cancel
    }
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
TimYatesCommented:
btw:  We cannot write the code for you, as that violates the "Academic Honesty" section in the Membership Agreement

http://www.experts-exchange.com/help.jsp#hi105
0
 
bloodredsunCommented:
>> The movie list must have at least one movie
You need to specify this in the constructor of this class, not the main() method.

>>Write a Java application called Oscar that
   - prompts the user to nominate 2 actors/actresses with their best movies,
   - prompts the user to nominate 3 best ever moviews from Hollywood,
For reading from the standard input, go here http://www.javaalmanac.com/egs/java.io/ReadFromStdIn.html

>>How would I use JOptionPane.showInputDialog(...) to get input from the user for both Actor and Movie objects.
I think it would be best to concentrate on the fundamentals of getting a command line version of this app running before we try to create a Swing-based GUI for it...

Sorry for not providing any code but as this appears to be homework or possibly a graded assignment, I can only help you in "teacher" mode.
0
 
bloodredsunCommented:
"Great Minds..." Tim!!!

(or is that "Fools seldom...") :-)
0
 
TimYatesCommented:
:-D  hehehe
0
 
duemesAuthor Commented:
I didnt ask you to write my code, but to assist ME in creating it....

THANKS for the information!
0
 
bloodredsunCommented:
>> I didnt ask you to write my code, but to assist ME in creating it....
>>THANKS for the information!

not at all :-)

Refering to your above post, at no time did we accuse you of cheating and we provided you with the information required for you to complete this piece of code. I'm sorry that you feel upset and need to shout (if you're unaware, ALL CAPS is the equivalent to shouting) but the only reason we're here is to assist people who are stuck with Java code issues.

All we did was to make clear that our hands are tied with regards to making any specific code for you. All the people in this thread (myself, TimYates and sudhakar_koundinya) have been helping people for some time with no little measure of success, both in feedback from posters and in the points awarded (you have the people currently at numbers 5,6 and 10 in the yearly list).

If you have any further issues with this project, post back here and I'm sure we will give it the attention it deserves.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now