首页 > 其他分享 >802第九次

802第九次

时间:2023-06-05 20:44:33浏览次数:29  
标签:Salary ColaEmployee double 第九次 test 802 super public

package xingzhuang;

public abstract class Shape {

 

double area;

double per;

String color;

public Shape() {

super();

}

public Shape(String color) {

super();

this.color = color;

}

public abstract double getArea();

public abstract double getPer();

public abstract void showAll();

public String getColor() {

return color;

}

}

//

package xingzhuang;

public class Rectangle extends Shape {

double Width;

double height;

public Rectangle() {

super();

}

public Rectangle(double width, double height,String color) {

super(color);

Width = width;

this.height = height;

}

public double getArea() {

double Area=Width*height;

return Area ;

}

public double getPer()

{

double Per=2*Width+2*height;

return Per;

}

public void showAll()

{

System.out.println("长:"+height);

System.out.println("宽:"+Width);

System.out.println("面积:"+getArea());

System.out.println("周长:"+getPer());

System.out.println("颜色"+color);

}

 

}

//

package xingzhuang;

public class Circle extends Shape{

 

public Circle() {

super();

}

 

public Circle(double radius,String color) {

super(color);

this.radius = radius;

}

double radius;

 

public double getArea() {

double Area=radius*radius*3.14;

return Area;

}

public double getPer()

{

double Per=2*3.14*radius;

return Per;

}

public void showAll()

{

System.out.println("半径:"+radius);

System.out.println("面积:"+getArea());

System.out.println("周长:"+getPer());

System.out.println("颜色"+color);

}

}

//

package xingzhuang;

public class menu {

public static void main(String[] args) {

// TODO Auto-generated method stub

Shape test_1=new Circle(2,"黑的");

Shape test_2=new Rectangle(5,5,"白的");

test_1.showAll();

test_2.showAll();

}

}

4、 Cola 公司的雇员分为以下若干类:(知识点:多态)[必做

题]

·4.1 ColaEmployee :这是所有员工总的父类,属性:员工的

姓名,员工的生日月份。方法: getSalary ( int month )根据参数月份来确定工资,如果该月员工过生日,则公司会额外奖励

100元。

4.2 SalariedEmployee :ColaEmployee 的子类,拿固定工

4.3 HourlyEmployee : ColaEmployee 的子类,按小时拿工资的员工,每月工作超出160小时的部分按照1.5倍工资发放。属性:每小时的工资、每月工作的小时数

·4.4 SalesEmployee : ColaEmployee 的子类,销售人员,工资由月销售额和提成率决定。属性:月销售额、提成率.4.5定义一个类 Company ,在该类中写一个方法,调用该方法可以打印出某月某个员工的工资数额,写一个测试类 TestCompany ,在 main 方法,把若干各种类型的员工在一个 ColaEmployee 数组里,并单元出数组中每个员工当月的工资。

资的员工。属性:月薪

//ColaEmployee类

package zxc;

 

public abstract class ColaEmployee {

String name;

int birthday;

public ColaEmployee() {

super();

}

public ColaEmployee(String name, int birthday) {

super();

this.name = name;

this.birthday = birthday;

}

public abstract double getSalary(int month);

 

}

 

 

//SalariedEmployee类

package zxc;

 

public class SalariedEmployee extends ColaEmployee{

double Salary;

 

public SalariedEmployee() {

super();

}

 

public SalariedEmployee(String name, int birthday,double salary) {

super(name,birthday);

Salary = salary;

}

 

public double getSalary(int month) {

if(birthday==month) {

Salary = Salary+100;

 

}

return Salary;

}

}

//HourlyEmployee类

package zxc;

 

public class HourlyEmployee extends ColaEmployee{

 

double Hour_Salary;

double Month_hour;

public HourlyEmployee() {

super();

}

public HourlyEmployee(String name, int birthday,double hour_Salary, double month_hour) {

super(name,birthday);

Hour_Salary = hour_Salary;

Month_hour = month_hour;

}

public double getSalary(int month) {

double Salary=0;

if(Month_hour>160) {

Salary=Hour_Salary*Month_hour+(Month_hour-160)*Hour_Salary*1.5;

}else if(Month_hour<=160){

Salary=Hour_Salary*Month_hour;

}

if(birthday==month)

        {

            Salary=Salary+100;

        }

        return Salary;

    }

}

 

//SalesEmployee类

package zxc;

 

public class SalesEmployee extends ColaEmployee{

int Moon_Sales;

    double Commission;

    

    public SalesEmployee() {

        super();

    }

 

    public SalesEmployee(String name, int birthday, int moon_Sales, double commission) {

        super(name, birthday);

        Moon_Sales = moon_Sales;

        Commission = commission;

    }

 

    public double getSalary(int month) {

        double Salary=0;

        Salary=Moon_Sales*Commission;

        if(birthday==month)

        {

            Salary=Salary+100;

        }

        return Salary;

    }

    

}

 

//Company类

package zxc;

 

public class Company {

public void ShowSalary(ColaEmployee test,int month)

    {

        System.out.println("员工:"+test.name+"\n月份:"+month+"\n工资状况:"+test.getSalary(month));

    }

}

 

//测试类

package zxc;

 

public class TestCompany {

public static void main(String[] args) {

 ColaEmployee[] test=new ColaEmployee[3];

     test[0]=new SalariedEmployee("cc",60,4000);

     test[1]=new HourlyEmployee("xx",6,300,800);

     test[2]=new SalesEmployee("zz",12,45000,0.2);

     Company show_fun=new Company();

     show_fun.ShowSalary(test[0], 5);

     show_fun.ShowSalary(test[1], 2);

     show_fun.ShowSalary(test[1], 3);

     show_fun.ShowSalary(test[2], 9);

     show_fun.ShowSalary(test[2], 10);

}

}

 

 

标签:Salary,ColaEmployee,double,第九次,test,802,super,public
From: https://www.cnblogs.com/shenyangkejixueyuan/p/17458895.html

相关文章

  • 2802ICT Intelligent System 智能系统
    Assignment22802ICTIntelligentSystemSchoolofICT,GriffithUniversityTrimester1,2023Instructions:•Due:Monday29thMay2023,11:59PMwithdemonstrationstobeheldonWeek12.•Marks:50%ofyouroverallgrade•Latesubmission:Latesubmissionis......
  • MATLAB仿真OFDM(802.11a)系统 程序 功能: 1、信道
    MATLAB仿真OFDM(802.11a)系统程序功能:1、信道为单径瑞丽衰落信道下,OFDM系统采用QPSK和16QAM调制时,接收机端采用理想信道估计和利用训练符号进行信道估计时的误比特率性能;2、比较OFDM系统在单径瑞丽信道与2径瑞丽信道下的误比特率性能。ID:7650643314980368......
  • 48024 python 代码分析
    ComputerScience220SC(2023)Assignment3(Basicgraphalgorithmsandtraversals)SeeCanvasforduedateThisassignmentrequiresyoutosubmitprogramsinPythonthatyouhavewrittenyourselftotheautomarker,https://www.automarker.cs.auckland.ac.nz.Yo......
  • 关于 nl80211
    本文译至:http://wireless.kernel.org/en/developers/Documentation/nl80211关于nl80211nl80211是新的802.11netlink接口公共头文件。加上cfg80211它的目的是取代Wireless-Extensions。nl80211和cfg80211仍在开发中。使用nl80211的工具nl80211的使用者是:iwcrdahostapd......
  • 关于cfg80211
    关于cfg80211cfg80211是Linux802.11配置API。cfg80211用于取代Wireless-Extensions。nl80211用来配置一个cfg80211设备,用于内核<->用户空间之间的通信。Wirelessextensions现在处于维护模式,将不会添加新的功到它上面,我们只修复bug。cfg80211现在与wireless-extensions是......
  • 180203 Jupyter Notebook and Markdown 插入图片位置并调整比例
    171111JupyterNotebook插入图片的4种方法MarkdownandimagealignmentExample:<imgstyle="float:right;"src="whatever.jpg"width="40%"><imgstyle="float:right;"src="https://timgsa.baidu.com/timg?image&qua......
  • 80211 RTS/CTS控制帧
    原文链接:https://blog.csdn.net/u014294166/article/details/129556001作为可选功能,802.11标准包括RTS/CTS(请求发送/清除发送)功能以控制AP对STA的访问。RTS/CTS出现的......
  • STAT802 分析
    STAT802–Assignment1,PartA.1STAT802:AdvancedTopicsinAnalytics-Semester12023STAT802Assignment1–PartADue:5pmonFriday24March2023Outlin......
  • 基于802.11n物理层的OFDM通信链路simulink仿真,包括FEC编码、插入导频、OFDM成帧、STB
    1.算法描述随5G的推广和下一代无线通信系统的兴盛,怎样应对现有频谱资源的紧缺与改善信息传输的质量成了迫在眉睫的难题,对重要技术的开发利用提出了更高的要求。其中,以MIMO......
  • Windows 11 Update Download Error Solution - 0x80248007
    IhadthesameissueonaWindows2019virtualserverwhileperformingroutinewindowsupdates.Theinstructionswerespoton.Iran:netstopwuauservnetst......