/**
 *  ShowUSA.java
 *  Provide a description here.
 *  @author Your Name Here
 *  @version 1.0
 *  @since 8/30/2016
 */
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.util.Scanner;

public class ShowUSAStart extends JFrame 
{
	/**
	 *  Creates a ShowUSA object, adding a JPanel
	 *  to the JFrame.
	 */
	public ShowUSAStart() 
	{
		super("United States of America");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		GetAndDrawCities cities = new GetAndDrawCities();
		getContentPane().add(cities);

		pack();
		setLocationRelativeTo(null);
		setVisible(true);
	}
	
	public static void main(String[] args)
	{
		new ShowUSAStart();
	}
}

/**
 *  Add comments.
 */
class GetAndDrawCities extends JPanel 
{
	private static final int PREF_W = 1000;
	private static final int PREF_H = 600;
	
	public GetAndDrawCities()
	{
		setBackground(Color.white);
	}

	@Override
	public Dimension getPreferredSize()
	{
		return new Dimension(PREF_W, PREF_H);
	}
	
	@Override
	public void paintComponent(Graphics g) 
	{
		super.paintComponent(g);
		addCities(g);
		addCapitals(g);
	}
	
	/**
	 *  Here, you should open up the cities text file, and translate the
	 *  numbers you find to coordinate values to be plotted.  The
	 *  dots should be gray and of diameter 4.
	 */
	public void addCities(Graphics g)
	{
		int diameter = 40;
		g.setColor(Color.black);
		g.fillOval(400-diameter/2,200-diameter/2,diameter,diameter);
	}
	
	/**
	 *  Open up the capitals text file, and, for each city you find in
	 *  this file, compare to the cities in cities.txt.  If you find a
	 *  match, print a red dot with diameter 12.
	 */
	public void addCapitals(Graphics g)
	{
	
	}
	
	public boolean checkForCapital(String city,String state)
	{
		return true;
	}
}

Back to APCS Main Page