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

📄 legacyline.java

📁 程序练习中包括书中实例程序代码和练习中要用到的代码,是压缩文件
💻 JAVA
字号:
package examples.collections;

import java.util.Vector;
import java.util.Enumeration;
import java.io.PrintStream;
import java.awt.Point;

/** A class to demonstrate the use of the Vector and
  * Enumeration classes in the java.util package
  */
public class LegacyLine {

   private Vector points = new Vector();

   /** Set the starting point for a line
     * @param p the starting point
     */
   public void setStart( Point p ) {
      points.removeAllElements();
      points.addElement( p );
   }

   /** Set the next point in a line
     * @param p the next point
     */
   public void addPoint( Point p ) {
      points.addElement( p );
   }

   /** Print all the points in a line
     * @param ps the stream where the points
     *           will be printed
     */
   public void listPoints( PrintStream ps ) {
      Enumeration e = points.elements();
      while ( e.hasMoreElements() ) {
         ps.println( e.nextElement() );
      }
   }

   /** Test method for the class
     * @param args not used
     */
   public static void main( String[] args ) {
      LegacyLine x = new LegacyLine();
      x.setStart( new Point( 4, 11 ) );
      x.addPoint( new Point( -6, 1 ) );
      x.addPoint( new Point( 2, 3 ) );
      x.listPoints( System.out );
   }
}

⌨️ 快捷键说明

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