Question: Can someone please correct my initializeShips ( ) method it should loads ship data from ship class to an ArrayList called flotilla and uses the

Can someone please correct my initializeShips() method it should loads ship data from ship class to an ArrayList called flotilla and uses the method call initializeShips("Tia_RosasFleet.csv")) using scanner and using the method called: initializeShips("Tia_RosasFleet.csv"); could you also look at my initSelectPanel() method im unable to get this to work. Could someone please fix and explain this. Thank you
import javax.swing.*;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.*;
import java.io.*;
public class ShipWindow extends JFrame
{
//dimensions of the window
private int wind_wid =650;
private int wind_hei =240;
JComboBox selectShipBox;
ArrayList flotilla = new ArrayList();
JTextField nameText, nationText,yearText, lenText, drafText, beamText;
String fileName =("Tia_RosasFleet.csv");
File inFile = new File(fileName);
public ShipWindow()
{
this.setTitle( "Shipping News ");
//set size using private variables as argument
this.setSize(wind_wid,wind_hei);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//initializeShips("Tia_RosasFleet.csv")
//initialize flotilla list by opening csv file and pass it file name
//of ship data
//initInfoPanel() create center zone;
//initButtonPanel(); m1_lect 3 add actionlistners to buttons
// insert all helper methods used to create and populate window application
// init.SelectPanel();
this.setVisible(true);
}
private void initializeShips(String fileName)
{
File inFile = new File(fileName);
try
{
Scanner inScan = new Scanner(inFile);
while (inScan.hasNext())
{
Ship ship = null;
String name = inScan.next();
String nation = inScan.next();
int year = inScan.nextInt();
int length = inScan.nextInt();
int draft = inScan.nextInt();
int beam = inScan.nextInt();
ship = new Ship(name, nation, year, length, draft, beam);
for(int i=0; i(shipNames));
selectShipBox = new JComboBox();
ImageIcon icon = new ImageIcon("Yacht_big.png");
int scalex =164;
int scaley =82;
JLabel iconLab = new JLabel(){
public void PaintComponent(Graphics g)
{
Image img = icon.getImage();//new object campable of being scaled
g.drawImage(img ,0,0, scalex,scaley, this);
}
};
iconLab.setPreferredSize(new Dimension(scalex, scaley));
iconLab.setIcon(icon);
JPanel northPan = new JPanel();
northPan.add(iconLab);
northPan.add(lab);
this.add(northPan,BorderLayout.NORTH);
}
public static void main(String[] args)
{
ShipWindow aw =new ShipWindow();
}
}class Ship
{
private String name; // Ship name
private String nation; // Nation of registry
private int yearBuilt; ??4 digit year built
private int length; ??? Length of ship at mean draft
private int draft;
 Can someone please correct my initializeShips() method it should loads ship

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!