CSE105 – Introduction to Java Programming

Lab 12 – Reading, Writing, Sorting, and Class Diagrams

Java编程代写 To improve your stock project by loading and sorting data. Previously, you created an arrayList of stockprice objects. 

Aim

To improve your stock project by loading and sorting data

List of Stock Objects Java编程代写

Previously, you created an arrayList of stockprice objects. You should also have created a method to write your objects to a file. This week, you will expand your project to use file reading and writing
• If you have not finished it already, modify your project to be able to write to file. Use the week 12 lecture notes as a guide and create a separate fileUtils class to contain your writeFile method
• This week, instead of creating your own stock objects, there is a list of 50 tickers in a csv file on ICE. Using the lecture notes, create a read file method from last week to read in this csv file
• There may be errors with your file reading, because your stock object may not be in the same format as your CSV file, so make changes to your code, but not the data
• Display the last, and check that the list in your program matches the file

LocalDate Objects Java编程代写

It is likely that your date object is likely implemented as a string. This makes it very hard to sort and search for. In the lecture notes, we introduced LocalDate, which helps with this
• Change your program so that you use LocalDate. You will need to change your constructors, getters, and possibly other method calls. Test that your file reading and writing still works.
• Do do this, you will need to create a method in your StockPrice to convert your String to a LocalDate. It should pass in a String and return a LocalDate

Java编程代写
Java编程代写

Sorting Stock Objects Java编程代写

If you look at your list of stock objects, you will see that they are not in any particular order. They are effectively shuffled. It would be nice to sort them into date order!
• Create a method to display all of your stocks on screen
• Using the lecture notes, implement comparable on your stockprice object. You will need to implement comparable in the class declaration. You will also need to create a “toCompare” method Java编程代写
• Your compare method will need to call “compareTo” to compare your dates. Again, use your lecture notes as a guide
• When you have implemented this, call the Collections.sort method in your main method and display
the result. Check that your list is now sorted by date!

Class Diagrams

In week 12, we showed how you could make class diagrams. Your StockPrice project should now be complete, with sorting, reading, writing, LocalDate, and appropriate comparison and searching methods, as well as a main and file utilities class
• Create a class diagram of your finished project. You can use paper or pen, or any drawing software. An autogenerated solution is not acceptable
• Use your lecture notes from week 11 as a guide Java编程代写

                                   

Coursework 3

Use the remaining time to work on your Coursework 3 assignment!