File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "program" Watch "program" New topic


Sam Gavis

Joined: Oct 27, 2007
Posts: 2
What is wrong with this program?

class Movie {
String title;
String genre;
int rating;

void playIt() {
System.out.println("Playing the movie");

public class MovieTestDrive {
public static void main(String[] args) {
Movie one = new Movie();
one.title = "Gone with the Stock";
one.genre = "Tragic";
one.rating = -2;
Movie two = new Movie();
two.title = "Lost in Cubicle Space";
two.genre = "Comedy";
two.rating = 5;
Movie three = new Movie();
three.title = "Byte Club";
three.genre = "Tragic but ultimately uplifting";
three.rating = 127;
Nacho Espinosa
Ranch Hand

Joined: Jan 17, 2007
Posts: 30
Something is wrong in the method playIt()

check it!

Greetings<br />Nacho Espinosa<br />SCJP 1.4
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46320
Welcome to the Ranch. Please use the "code" tags when posting code; it makes it much easier to read.

You are putting info into the Movie objects and not accessing it again. You are not calling the playIt method anywhere.

Move the Movie class into a file of its own and give the class public access. Please make all the attributes "private" and set up a public constructor in the Movie class. Also public access for the playIt method.
Then you can call it more like this:Give the Movie identifiers better names than one, two, three.
Alter the playIt method so it prints out something more informative.

I hope that lot is helpful-and I am not trying to be critical.
I agree. Here's the link:
subject: program
jQuery in Action, 3rd edition