This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
but right now i want to take tha m1......m25 from a file not from the main. Can you help me please?
First of all you should look at using a collection rather than variables m1 to m25. If you use something like an ArrayList to hold your movies you can add as many as you like at a later date without changing your code, with your current way of doing things changing the number of movies will require code changes.
Before we can suggest how to read the data from a file you need to tell us how the data is stored in the file.
Joined: Jan 03, 2014
I don't like either the m1...m25 but its how the teacher gave it to us.
Right now i don't have a file or anything because teacher just told us "put what you thing in a File and the read them from it." Thats why I dont know from where to start.
I know how to put data into files but I dont know how with these and what happening with the subclasses.
Joined: Aug 07, 2007
Presumably now you are reading the data in from a file you can change from m1-m25 to an ArrayList.
You need to decide how you want to structure the data in your file ie CSV, XML etc. Probably the easiest way is to use something like a CSV format with one line of data for each movie. I suggest you google for CSV files.
Reading a line of data at a time is easy (google for something like 'java read line'). Then you need to split the line you have read in at each comma (Hint: the String class has a method for doing this).
You will need to parse each piece of numeric data to convert it from a String to an int (see the Integer class) and then you can construct the appropriate Movie object.