zoukankan      html  css  js  c++  java
  • 第二十次发博不知道用什么标题好

    package Test;
    
    public class Superperson {
        private String name;
        private int age;
    
        public Superperson() {
    
        }
    
        public Superperson(String name) {
            this.name = name;
        }
    
        public Superperson(int age) {
            this.age = age;
        }
    
        public Superperson(String name, int age) {
            this.name = name;
            this.age = age;
        }
    
        public String getName() {
            return name;
        }
    
        public void setName(String name) {
            this.name = name;
        }
    
        public int getAge() {
            return age;
        }
        
        public void setAge(int age) {
            if(age<0) {
                this.age=0;
            }else {
                this.age=age;
            }
        }
        public void printMessage() {
            System.out.println("name=" + name + ",age=" + age);
        }
    
        public void addAge() {
            age++;
        }
    
    }
    
    
    package Test;
    
    public class Iperson {
        
            
    
        public static void main(String[] args) {
            Superperson p1 = new Superperson("小明",18);
            p1.addAge();
            p1.printMessage();
            
            Superperson p2 = new Superperson("小红");
            p2.setAge(20);
            p2.addAge();
            p2.printMessage();
            
            Superperson p3 = new Superperson();
            // TODO Auto-generated method stub
    
        }
    
    }

    这么久以来...第一次直接把代码复制粘贴...感觉一般般吧

  • 相关阅读:
    HelloJava.java
    建表
    JAVA连接数据库
    数据查询
    时间片轮转法
    最高优先级
    进程调度
    磁盘调度管理
    Fibonacci数列
    众数问题
  • 原文地址:https://www.cnblogs.com/shi-yuan/p/10777420.html
Copyright © 2011-2022 走看看