Advertisement
Guest User

xd

a guest
Jan 19th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. 3. Your next task is implement a class that will read in the data from the data file. Call
  2. your class ProcessCities, then implement the following:
  3. a) The class should have TWO instance variables:
  4. • An InputReader which will be used to read the data
  5. • An ArrayList of City objects
  6. (3 marks)
  7. b) A constructor that will assign values to each of the two instance variables by
  8. constructing objects of the appropriate type. (4 marks)
  9. c) A method called processData which will read the data. Carefully read the
  10. description in the Appendix which describes the format of the input file
  11. and the methods of the InputReader. Your code should:
  12. • Declare a local variable of type String[] and assign it the value returned
  13. from the getInputLine method of the InputReader. The array that you
  14. get back will contain a single value, which will be a string of digits being the
  15. number of lines of data in the file. Convert the string of digits into an int
  16. using the method convertToInt defined for you in the InputReader
  17. class.
  18. • Using a FOR statement, read the number of lines of input indicated by the
  19. value read from the first line of the data file. In the body of the for
  20. statement, use the getInputLine method of the InputReader to get a
  21. line of data. Use the array of data values to:
  22. – construct a Location object using the latitude and longitude from the
  23. input line. Note that you will need to convert the latitude and longitude
  24. values from a string of digits to an double. The InputReader class
  25. has a method called convertToDouble to do that for you.
  26. – construct a City using the name, the population, the county from the
  27. input data and the location object.
  28. – add the City to your ArrayList.
  29. (15 marks)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement