public void display()
{
String format = "%1s %n";
String name="Country";//sets country to print in the header
String capital="Capital";//sets captial to print in the header
String region="Region";//sets regiong to print in the header
String regionNmb= "Region Number";//sets region number to orint in the header
String pop="Capital Population";//sets catiptial population to print in the header
System.out.printf ("%-27s %-30s %-23s %-17s %-20s %n %n %n",name, capital,region,regionNmb,pop);//header
for (int i=0; i < 43; i++)//for loop to print out array of countrues
System.out.format(String.format(format, (Object[])country));//country is an array
//System.out.println(country[i]);
//System.out.println("");
}
This is the code where my attributes are located.
package project1barry;
public class CountryData
{
private String countryName;//sets the strings and integers
private String countryCapital;
private String countryRegion;
private int countryRegionNumber;
private int countryPopulation;
public CountryData
(String countryName, String countryCapital, String countryRegion, int countryRegionNumber, int countryPopulation)
{
this.countryName = countryName;//reference to current object
this.countryCapital = countryCapital;//reference to current object
this.countryRegion = countryRegion;//referenceto current object
this.countryRegionNumber = countryRegionNumber;//reference to current object
this.countryPopulation = countryPopulation;//reference to current object
}
public String getCountryName()
{
return countryName;// returns value from the method
}
public String getCountryCapital()
{
return countryCapital;
}
public String getCountryRegion()
{
return countryRegion;
}
public int getCountryRegionNumber()
{
return countryRegionNumber;
}
public int GetCountryPopulation()
{
return countryPopulation;
}
public String toString()
{
String s = countryName + "\t\t\t" + countryCapital + "\t\t\t" + countryRegion + "\t\t\t" + countryRegionNumber + "\t\t "+ countryPopulation;
return s;
}
} //Closes CountryData Class
Any help is greatly appreciated.

New Topic/Question
Reply




MultiQuote




|