• 第九周上机作业


    package Wxte;
    import java.util.Scanner;
    
    public class Person {
    	int x;
        int y;
        Person() {
                  
        }
        Person(int dx,int dy) {
            x+=dx;
            y+=dy;
                  
        }
        void movepoint(int p1,int p2) {            
            p1=x*2;
            p2=y*2;
            System.out.println("p1的坐标"+p1+"
    "+"p2的坐标"+p2);              
        }
        
        
    }
    

      

    package Wxte;
    import java.util.Random;
    import java.util.Scanner;
    
    public class Mast {
    
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		Person p=new Person();
    	        p.x=6;
    	        p.y=7;
    	       p.movepoint(p.x,p.y);
    	 }
    	}
    

      2.

    package Wxte;
    import java.util.Scanner;
    
    public class Person {
    	 int length;
    	    int width;
    
    	    public  Person(int length, int width) {
    	        this.length = length;
    	        this.width = width;
    	    }
    
    	    public int getArea() {
    	        return length * width;
    	    }
    
    	    public int getPer() {
    	        return 2 * (length + width);
    	    }
    
    	    void showAll() {
    	        System.out.println("长为" + length + ",宽为" + width + ",面积为" + getArea() + ",周长为" + getPer());
    	    }
    
    	    public static void main(String[] args) {
    	    	 Person a = new  Person(5 ,3);
    	        a.showAll();
    	         }
    
    	    }
    

      3.

    package Wxte;
    import java.util.Scanner;
    
    public class Person {
    	 char color;
    	    int  model;
    	    Person(){   
    	    }
    	    Person(char color,int model){
    	        this.color=color;
    	        this.model=model;
    	    }
    	    public void info() {
    	        System.out.println("笔记本信息:"+color+" "+model);
    	    }
    	}
    

      

    package Wxte;
    import java.util.Random;
    import java.util.Scanner;
    
    public class Mast {
    
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		 Person a=new  Person('蓝',16);
             a.info();
     }
    }
    

      4.

    package Wxte;
    import java.util.Scanner;
    
    public class Person {
    	private String name;
        private int age;
        private float heigh;
        public Person(String name,int age,float heigh) {
            this.name=name;
            this.age=age;
            this.heigh=heigh;
        }
        
        
        public void sayHello() {
            System.out.println("hello,my name is "+name+" 我的年龄为"+age+" 我的身高为"+heigh+"cm");
        }
    }
    

      

    package Wxte;
    import java.util.Random;
    import java.util.Scanner;
    
    public class Mast {
    
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		 Person p =new Person("张三",34,175);
    	        Person m =new Person("李四",46,177);
    	        p.sayHello();
    	        m.sayHello();
    	    }
     }
    

      

  • 相关阅读:
    CKEditor 5 摸爬滚打(二)—— 自定义一个简单的加粗插件(上)
    由数组生成对称矩阵
    二终端网络可靠度
    多分类建模评估指标
    linux文本编辑器awk
    sklearn中的pipeline实际应用
    一觉醒来,我掉入计算机之中了···
    一个故事看懂计算机操作系统的进化史
    我是如何把计算机网络考了100分的?
    大一那会,我用QQ远程帮同学考过计算机二级
  • 原文地址:https://www.cnblogs.com/575757ljp--/p/12821037.html
Copyright © 2020-2023  润新知