zoukankan      html  css  js  c++  java
  • Java课第四次作业

    /**
     * 
     */
    
    /**
     * @author asus
     *
     */
    public class 作业 {
    
    	/**
    	 * @param args
    	 */
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		Dog dog=new Dog("金毛","黄色",9);
    		  System.out.println(dog);
    		 }
    		}
    	class Dog {
    		private String name;
    		private String color;
    		private int age;
    		public String getName(){
    		return name;
    	}
    	public String getColor(){
    		return color;
    	}
    	public int getAge(){
    		return age;
    	}
    	public void setName(String name){
    		this.name=name;
    	}
    	public void setColor(String color){
    		this.color=color;
    	}
    	public void setAge(int age){
    		this.age=age;
    	}
    	public Dog(String name,String color,int age){
    		super();
    		this.name=name;
    		this.color=color;
    		this.age=age;
    	}
    	public String toString(){
    		return "狗的名字:"+this.name+",狗的年龄:"+this.age+",狗的颜色:"+this.color;
    	}
    
    }
    

      

    /**
     * 
     */
    
    /**
     * @author asus
     *
     */
    public class 作业 {
    
    	/**
    	 * @param args
    	 */
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    				User user1=new User("燕勇鹏","别动");
    				user1.print();
    				User user2=new User("张钊","别玩游戏");
    				user2.print();
    				new User().count();
    			}
    		}
    		class User
    		{
    			private String name;
    			private String password;
    			private static int count;
    			public User(){
    			count++;
    		 }
    		public User(String name){
    			this.name=name;
    			count++;
    		}
    		public User(String name,String password){
    			this.name=name;
    			this.password=password;
    			count++;
    		}
    		public String getName(){
    			return name;
    		}
    		public void setName(String name){
    			this.name=name;
    		}
    		public String getPassword(){
    			return password;
    		}
    		public void setPassword(String password){
    			this.password=password;
    		}
    		public void print(){
    			System.out.println("用户名:"+name+"	"+"口令:"+password);
    		}
    		public void count(){
    			System.out.println("用户个数:"+(count-1));
    		 }
    		}
    

      

  • 相关阅读:
    CreateDIBSection函数
    rand()和srand()GetTickCount函数用法
    PRIMARY LANGUAGE ID not a number
    videojs 动态加载视频
    [记录] nicescroll 在bootstrap tabs中工作
    [记录] js判断数组key是否存在
    li 水平排列并自动填满 ul
    [Laravel] 获取执行的Sql
    [Laravel]配置路由小记
    昨天冲动的搬到外面住了,oh yeah
  • 原文地址:https://www.cnblogs.com/yypfd/p/6607195.html
Copyright © 2011-2022 走看看