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

📄 line.java

📁 简单的JAVA小程序,可以读取文档,根据你TXT文件里的数值进行简单符号画图
💻 JAVA
字号:
public class Line {
	boolean isHorizontal; 
   	int length;
   	boolean isEdge=true;

   	public static void PrintUnderLined( String sentence ){
     		System.out.println(sentence);
     		for (int i=0;i<sentence.length();i++){
        		System.out.print("=");
     		}
   	}// end of method PrintUnderLined

	public Line( boolean isHorizontal, int length ) {
         	this.isHorizontal=isHorizontal;
      		this.length=length;
   	}//end of constructor

	public Line(boolean isHorizontal){
      		this.isHorizontal=isHorizontal;
   	}

 	public String getName(){
      		if (isHorizontal==true) {
         		return "Horizontal Line" ;
      		} 
      		else {
         		return "Vertical Line";
      		}
   	}// end of method getName   

	public void print(){
       	if (isHorizontal==true) {
           		PrintUnderLined("PrintVertical Line Properties");
    
        		System.out.println("\nOrientation is Vertical Line");
        		System.out.println("length is "+length);
      		}
      		else {
        		PrintUnderLined("Vertical Line Properties");
   
        		System.out.println("\nOrientation is Vertical Line");
        		System.out.println("length is "+length);
      		}
    
   	}// end of method print

	public String toASCIIDrawing(){
     		String a=new String();
      			if (isEdge==true){
       			if (isHorizontal==true) {
         				for (int i=0;i<length;i++){
             					if (i==0 || i==length-1){
               		 			a+="+";
             					} else {
                					a+="-";               
               				}
                     		}// end of for
         				return a;
       			}  
       			else {
         				for (int j=0;j<length;j++){
             					if (j==0 || j==length-1){
                					a+="+";
                					a+="\n";
             					}
               				else {
                					a+="|";
                					a+="\n";              
               				}
                  			}// end of for
            				return a;
       			}  
       		}
       		else  {
        			for (int k=0;k<length;k++){
           				if (k==0||k==length-1){
               				a+="|";
           				}
           				else{
               				a+=" ";
           				}
        			}
           			return a;
      			}
      
   	}// end of toASCIIDrawing() method

  	public void setLength(int a){
      		length=a;
   	} 
   
   	public int getLength(){
      		return length;
   	}
   
   	public void setIsHorizontal(boolean a){
      		isHorizontal=a;
   	}
   
   	public boolean getIsHorizontan(){
      		return isHorizontal;
   	}
   	
	public void setIsEdge(boolean a){
      		isEdge=a;
   	}

   	public boolean getIsEdge(){
      		return isEdge;
   	}

}//end of class

⌨️ 快捷键说明

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