1、 实验内容
1) 设计一个Point类,该类包含两个int类型的成员变量:x、y,一个Color类型的成员变量mycolor。请给出此类的构造方法,分别是一个不带参数的,一个带两个参数的,一个带三个参数的构造方法。还要给出对应的get方法和t方法,最后重写equals和toString方法。
2) Vector类的使用。要求:编写一个程序,创建Vector类的实例vectorInstance;随机产生[0,100]之间的3个整数,依次插入到vectorInstance中;将字符串“hello world”,插入到vectorInstance的末尾。将字符‘A’,插入到vectorInstance的第一个位置;在显示器上输出vectorInstance中的所有数据。
3) 一个公司,拥有普通员工、行政人员和经理三类员工,全体员工的工资都包括:基本工资、奖金,同时享受医疗保险和劳动保险。行政人员和经理还享受车补;经理还有内部分红。请你为该公司设计一个简单的工资管理程序。
九、程序清单
1>package imut.cstd.j09_2;
import java.awt.Color;
public class Point {
private int x;
private int y;
private Color mycolor;
public Point(){
x=0;
y=0;
mycolor=null;
}
public Point(int x,int y){
this.x=x;
this.y=y;
}
十二生肖成语大全
public Point(int x,int y,Color mycolor){
this.x=x;
this.y=y;
this.mycolor=mycolor;
}
public int getX(){
return x;
}
public int getY(){
return y;
}
public Color getMycolor(){
return mycolor;
}
public void tX(int x){
this.x=x;
}
public void tY(int y){
this.y=y;
怎么做小笼包
}
public void tMycolor(Color mycolor){
this.mycolor=mycolor;
}
public String toString(){
return "X="+x+"\n"+"Y="+y+"\n"+"Mycolor="+mycolor;
}
public boolean equals(Object p){
if(p==null)return fal;
if(!(p instanceof Point))return fal;
Point temp=(Point)p;
if((mycolor==null)&&(temp.mycolor==null)&&(x==temp.x)&&(y==temp.y))return true;
if(!(temp.mycolor==null)&&(mycolor.equals(temp.mycolor))&&(x==temp.x)&&(y==temp.y))return true;
el return fal;
}
public static void main(String[] args){
Point p=new过年送什么礼物给长辈 Point();
System.out.println(p);
王者荣耀人工客服专线
Point p1=new Point(2,2,new Color(45));
Point p2=new Point(2,2,new Color(45));
System.out.print(p1+"和"+p2+"相等?"+p1.equals(p2) +"\n");
Point p3=new Point(5,4);
Point p4=new Point(5,4);
System.out.print(p3+"和"+p4+"相等?"+p3.equals(p4)+"\n");
Point p5=new Point(2,4);
Point p6=new Point(5,4);
System.out.print(p5+"和"+p6+"相等?"+p5.equals(p6));
}
}
2>package imut.cstd.j09_2;
import java.util.Vector;
public class Connect {
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void main(String[] args){
Vector vectorInstance = new Vector();
vectorInstance.add("A");
for(int i=0;i<3;i++){
int rand=(int)(Math.random()*101);
vectorInstance.add(rand);
}
vectorInstance.add("hello world");
for(int i=0;i<vectorInstance.size();i++)
System.out.(i));
}
}
3>package imut.cstd.j09_2;
public class Employee {
private float wages;
private float reward;
private float meinsure;
private float lainsure;
public Employee(){
this(0.0f,0.0f,0.0f,0.0f);
}
public Employee(float wages,float reward,float meinsure,float lainsure){
this.wages=wages;
this.reward=reward;
this.meinsure=meinsure;
this.lainsure=lainsure;
}
public float getWages(){
return wages;
}
关于长征的小故事public float getReward(){
return reward;
}
public float getMeinsure(){
return meinsure;
}
public float getLainsure(){
return lainsure;
}
public void tWages(float wages){
this.wages=wages;
}
public void tReward(float reward){
this.reward=reward;
}
public void tMeinsure(float meinsure){
this.meinsure=meinsure;
}
public void tLainsure(float lainsure){
this.lainsure=lainsure;
}
public String toString(){
return "工资"+getWages()+"\t奖金"+getReward()+"\t医保"+getMeinsure()+"\t劳保"+getLainsure();
}
public float salarysum(){
return getWages()+getReward()+getMeinsure()+getLainsure();
}
}
package imut.cstd.j09_2;
public class Officeholder extends Employee{
private float chebu;
public Officeholder(){
this(0.0f,0.0f,0.0f,0.0f,0.0f);
}
public Officeholder(float wages,float中秋赏月作文 reward,float meinsure,float lainsure, float chebu) {
this.tWages(wages);
this.tReward(reward);
this.tMeinsure(meinsure);
this.tLainsure(lainsure);
this.chebu=chebu;
}
public float getChebu(){
return chebu;
}
public void tChebu(float chebu){
this.chebu=chebu;
}
public String toString(){
return "工资"+getWages()+"\t奖金"+getReward()+"\t医保"+getMeinsure()+"\t劳保"+getLainsure()+"\t车补"+getChebu();
}
public float医院英文翻译 salarysum(){蒙昧什么意思
return getWages()+getReward()+getMeinsure()+getLainsure()+getChebu();
}
}
package imut.cstd.j09_2;
public class Manager extends Officeholder{
private float fenhong;
public Manager(){
this(0.0f,0.0f,0.0f,0.0f,0.0f,0.0f);
}
public Manager(float wages,float reward,float meinsure,float lainsure, float chebu,float fenhong) {
this.tWages(wages);
this.tReward(reward);
this.tMeinsure(meinsure);
this.tLainsure(lainsure);
this.tChebu(chebu);
this.fenhong=fenhong;