What is "s"? variable names should show what the contents of the variable. "s" has no meaning.
Did you read my last post? The method that builds the Vector still does not return it so other methods can use it.
The code's formatting is still poor.
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.
What is "s"? variable names should show what the contents of the variable. "s" has no meaning.
Did you read my last post? The method that builds the Vector still does not return it so other methods can use it.
The code's formatting is still poor.
If you don't understand my answer, don't ignore it, ask a question.
s is the variable rating
i dont know how else to format the code
A better name would be currMaxRating??? instead of s. Does it hold an index or is it a reference to a film object or the value of the max rating?
Format it so that the }s are in the same column beneath the start of the line that has the {how else to format the code
Very few things should be in the first column:
public class
and the ending } for the class.
If you don't understand my answer, don't ignore it, ask a question.
it holds the value of the rating
The code has to save where that value came from.
Either a reference to the object
or an index into the Vector for where that object is stored.
If you don't understand my answer, don't ignore it, ask a question.
I have it printing out the highest rated film now not sue if its the correct way but its doing waht i want it to do thanks for the help
//******************QUESTION**********************\\
Create a simple text file that contains information on Films like that in question 1. The format of the file may look like this:
Top Gun, Tom Cruise, 110, 3.7, 1012
Training Day, Denzel Washington, 122, 4.5, 21786
.....
5 or 6 entries will suffice for this example but your program should work with many more.
Write a Java method called populateFilmVector(String path) to do the following:
i. Read the Film file line by line and tokenize each line to get the Film attributes.
ii. Create a Film object from the tokens (You may need to do some type conversions here).
iii. Add the Film object to the Vector (this Vector will be a class variable with class scope)
Question 3
Write a method called bestFilm() that searches through the FilmVector and returns the best film based on the ratings. The method should return the Film object
************************************************** ***************
that was the program i had to write
That's a start. As you get more experience you'll be able to improve the techniques you've used.
If you don't understand my answer, don't ignore it, ask a question.
dubs4sam (April 18th, 2014)
thanks for your help