zoukankan      html  css  js  c++  java
  • 作业

    class Employer{
    private String name;
    private int age;
    private char sex;
    public Employer(){
    }
    public Employer(String name,int age,char sex){
    super();
    this.name=name;
    this.age=age;
    this.sex=sex;
    }
    public String toString(){
    return "雇员姓名:"+this.name+" 年龄:"+this.age+
    " 性别:"+this.sex;
    }
    }
    class Manager extends Employer{
    private String job;
    private double income;
    public Manager(){
    }
    public Manager(String name,int age,char sex,String job,double income){
    super(name,age,sex);
    this.job=job;
    this.income=income;
    }
    public String toString(){
    return super.toString()+" 职位:"+this.job+" 年薪:"+this.income;
    }
    }
    class Staff extends Employer{
    private String dept;
    private double salary;
    public Staff(){
    }
    public Staff(String name,int age,char sex,String dept,double salary){
    super(name,age,sex);
    this.dept=dept;
    this.salary=salary;
    }
    public String toString(){
    return super.toString()+" 部门:"+this.dept+" 月薪:"+this.salary;
    }
    }
    public class per03 {

    /**
    * @param args
    */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    Employer ea=new Manager("小刘",22,'男',"经理",100000.0);
    Employer eb=new Staff("小崔",23,'男',"销售",3000.0);
    System.out.println(ea);
    System.out.println(eb);
    }
    }

    abstract class Shape{
    public abstract double area();
    public abstract double perimeter();
    }
    class Rectangle extends Shape{
    private double wide;
    private double longs;
    public Rectangle(){
    }
    public Rectangle(double wide,double longs){
    super();
    this.wide=wide;
    this.longs=longs;
    }
    public double area(){
    return this.longs*this.wide;
    }
    public double perimeter(){
    return (this.longs +this.wide)*2;
    }
    }
    class Triangle extends Shape{
    private double edgea;
    private double edgeb;
    private double edgec;
    public Triangle(){
    }
    public Triangle(double edgea,double edgeb,double edgec){
    super();
    this.edgea=edgea;
    this.edgeb=edgeb;
    this.edgec=edgec;
    }
    public double area(){
    return this.edgea*this.edgeb/2;
    }
    public double perimeter(){
    return this.edgea+this.edgeb+this.edgec;
    }
    }
    class Round extends Shape{
    private double radius;
    public Round(){
    }
    public Round(double radius){
    super();
    this.radius=radius;
    }
    public double area(){
    return this.radius*this.radius*Math.PI;
    }
    public double preimeter(){
    return this.radius*2*Math.PI;
    }
    @Override
    public double perimeter() {
    // TODO Auto-generated method stub
    return 0;
    }
    }
    public class per04 {

    /**
    * @param args
    */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    Shape rectangle=new Rectangle(12.5,30.6);
    Shape triangle=new Triangle(12.4,30.2,40.3);
    Shape round=new Round(40.4);
    System.out.println("矩形面积:"+rectangle.area()+" 矩形周长:"+rectangle.perimeter());
    System.out.println("三角形面积:"+triangle.area()+" 三角形周长:"+triangle.perimeter());
    System.out.println("圆形面积:"+round.area()+" 圆形周长:"+round.perimeter());
    }

    }

  • 相关阅读:
    runlevel=$(set -- $(runlevel); eval "echo $$#" )
    MPLS
    sql server 查询存储过程返回值
    sql 游标的关闭和释放
    sql 查询某一列最大的数据
    flex label如何通过AS3实现颜色设置
    sql server 字符串拆分
    Linux centos 解决"不在 sudoers 文件中。此事将被报告"的问题
    Flex String拼接
    flex 判断对象的类型
  • 原文地址:https://www.cnblogs.com/hell/p/5369237.html
Copyright © 2011-2022 走看看