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

📄 usepoint.java

📁 递归子程序法:对应每个非终结符语法单元编一个独立的处理过程(或子程序)。语法分析从读入第一个单词开始
💻 JAVA
字号:
	/** 
	 * Java语言实验参考程序
	 * Company 北京师范大学计算机系 
	 * @author 孙一林
	 * @version 1.0
	 */
	class Point {							// 声明一个“点”类
	  private int x0;
	  private int y0;
	  private int x;
	  private int y;
	  public Point() {
	    this.x0 = 0;
	    this.y0 = 0;
	    this.x = 0;
	    this.y = 0;
	  }
	  public Point(int newX0,int newY0) {
	    this.x0 = newX0;
	    this.y0 = newY0;
	    this.x = newX0;
	    this.y = newX0;
	  }
	  public void setX(int newX) {
	    x = newX + x0;
	  }
	  public int getX() {
	    return x;
	  }
	  public void setY(int newY) {
	    y = newY + y0;
	  }
	  public int getY() {
	    return y;
	  }
	}
	public class UsePoint {
	  public static void main(String[] args) {
	    Point point1 = new Point();				// 创建“point1”的对象
		point1.setX(20);						// 移动“点”
		point1.setY(10);						// 调用Point类中setY()方法
	    System.out.println(point1.getX());		// 调用Point类中getX()方法
	    System.out.println(point1.getY());		// 调用Point类中getY()方法
	    Point point2 = new Point(10,10);		// 创建“point2”的对象
		point2.setX(20);						// 移动第二个“点”
		point2.setY(10);						// 调用Point类中setY()方法
	    System.out.println(point2.getX());		// 调用Point类中getX()方法
	    System.out.println(point2.getY());		// 调用Point类中getY()方法
	  }
	}

⌨️ 快捷键说明

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