| | |
James Bond Search Program
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2008
Posts: 37
Reputation:
Solved Threads: 0
I was given a movie list, and I was asked to make a program to retrieve information from it and eventually modify the program to find certain movies. Right now I have a Collection class and a Movie class. The Movie class look like this:
The Collection class is the one I'm having difficulty with retrieving the file. I have it in the file with the program and it's all directed correctly to my understanding...
I get ") missing" on the line
I get an error with a ')' expected for the Collection class on and I don't know why.
Any help appreciated...
Java Syntax (Toggle Plain Text)
import chn.util.*; import apcslib.*; public class Movie implements Comparable { private String myTitle; // title of Bond film private String myBondActor; // name of actor of portrayed James Bond private int myYear; // year film was released private double myFilmRating;// from all-reviews.com private int myLengthHours; // hours (truncated) portion of film length private int myLengthMinutes;// minutes beyond truncated hours public Movie (String title, String name, int yr, double rating, int hrs, int min) { myTitle = title; myBondActor = name; myYear = yr; myFilmRating = rating; myLengthHours = hrs; myLengthMinutes = min; } public String getTitle() { return myTitle; } public String getBondActor() { return myBondActor; } public int getYearFilmReleased() { return myYear; } public double getFilmRating() { return myFilmRating; } public int getFilmHrs() { return myLengthHours; } public int getFilmMin() { return myLengthMinutes; } public int compareTo(Object other) { return (int)(myFilmRating*10) - (int)((((Movie)other).myFilmRating)*10); } public String toString() { return (Format.left(myTitle,34) + Format.left(myBondActor,16) + Format.center(myYear,6) + Format.center(myFilmRating,7,1) + " " + myLengthHours + " hr " + myLengthMinutes + " min"); } }
The Collection class is the one I'm having difficulty with retrieving the file. I have it in the file with the program and it's all directed correctly to my understanding...
Java Syntax (Toggle Plain Text)
import chn.util.*; import apcslib.*; public class Collection { private Movie[] movieList; public Collection(String fileName = "../TMJamesBond.java/movies.txt") loadData(fileName = "../TMJamesBond.java/movies.txt"); } private void loadData(String fileName = "../TMJamesBond.java/movies.txt") { String movieTitle; String bondName; int yearReleased; double movieRating; int lengthHours; int lengthMinutes; FileInput inFile = new FileInput(); int numReleases = inFile.readInt(); movieList = new Movie[numReleases]; for (int i = 0; i < numReleases; i++) { movieTitle = inFile.readLine(); bondName = inFile.readLine(); yearReleased = inFile.readInt(); movieRating = inFile.readDouble(); lengthHours = inFile.readInt(); lengthMinutes = inFile.readInt(); movieList[i] = new Movie(movieTitle, bondName, yearReleased, movieRating, lengthHours, lengthMinutes); } } public void displayInfo() { System.out.print(Format.center("Film Title",34)); System.out.print(Format.center("Bond Actor",16)); System.out.print(Format.center("Year",6)); System.out.print(Format.center("Rating",7)); System.out.print(Format.right("Film Length",16)); System.out.println(); System.out.println(); for (int i = movieList.length - 1; i >= 0 ; i--) { String output = movieList[i].toString(); System.out.println(output); } } public void Sort() { selectionSort(movieList); } /** * Sorts Student objects in an array * index using a selectionSort algorithm. * * @param list an array of type Student */ void selectionSort (Movie[ ] List) { int min; for (int outer = 0; outer < List.length - 1; outer++) { min = outer; for (int inner = outer + 1; inner < List.length; inner++) { if (List[inner].compareTo(List[min]) < 0) { min = inner; // a new smallest item is found } } //swap list [outer] & list [flag] Movie temp = List [outer]; List[outer] = List [min]; List [min] = temp; } } public static void main(String[] args) { Collection seriesData = new Collection("../TMJamesBond.java/movies.txt"); seriesData.Sort(); seriesData.displayInfo(); } }
I get ") missing" on the line
I get an error with a ')' expected for the Collection class on
Java Syntax (Toggle Plain Text)
loadData(fileName = "../TMJamesBond.java/movies.txt");
Any help appreciated...
Java Syntax (Toggle Plain Text)
public class Collection { private Movie[] movieList; public Collection(){ loadData("../TMJamesBond.java/movies.txt"); } private void loadData(String fileName) { // REST OF THE CODE
Have look at Classes and Objects tutorial and take special care to read Defining Methods chapter
PS: Program still has lot of errors....
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
- expert! how to do this? PHONEBOOK! (C++)
- Freeprodtb!! (Viruses, Spyware and other Nasties)
Other Threads in the Java Forum
- Previous Thread: Extending java.nio.ByteBuffer
- Next Thread: Is it possible to create such a web based Instant Message System?
| Thread Tools | Search this Thread |
3d @param affinetransform android api applet application arc arguments array arrays automation binary bluetooth byte capture chat class classes click client code color compare component count database design detection eclipse eclipsedevelopment encryption error event exception fractal game givemetehcodez graphics gridlayout gui guitesting helpwithhomework html ide if_statement image input integer interface j2me java java.xls javaprojects jni jpanel julia keytool keyword linux list loop macintosh map method methods mobile netbeans newbie object os pong print problem producer program programming project projectideas read recursion replaysolutions rim scanner screen server set size sms sort sql string swing terminal threads transforms tree ui web windows






