⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 countryinfo.java

📁 java源程序 对初学者有很大的帮助 从简单到复杂
💻 JAVA
字号:
//********************************************************************
//  CountryInfo.java       Author: Lewis/Loftus
//
//  Represents a country's demographic information.
//********************************************************************

import java.io.Serializable;

public class CountryInfo implements Serializable
{
   private String name, abbreviation, capitol;
   private long area, population;

   //-----------------------------------------------------------------
   //  Sets up this object by storing the specified information.
   //-----------------------------------------------------------------
   public CountryInfo (String cName, String cAbbreviation,
                       String cCapitol, long cArea, long cPopulation)
   {
      name = cName;
      abbreviation = cAbbreviation;
      capitol = cCapitol;
      area = cArea;  // measured in square kilometers
      population = cPopulation;
   }

   //-----------------------------------------------------------------
   //  Returns the information in this object as a string.
   //-----------------------------------------------------------------
   public String toString()
   {
      String result = "Name: " + name + "\n";
      result += "Abbreviation: " + abbreviation + "\n";
      result += "Capitol: " + capitol + "\n";
      result += "Area: " + area + " square kilometers\n";
      result += "Population: " + population + "\n";
      result += "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^";

      return result;
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -