abstract class Person{
創(chuàng)新互聯(lián)從2013年創(chuàng)立,是專業(yè)互聯(lián)網(wǎng)技術服務公司,擁有項目做網(wǎng)站、成都網(wǎng)站制作網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元安居做網(wǎng)站,已為上家服務,為安居各地企業(yè)和個人服務,聯(lián)系電話:13518219792
private String name;
private String post;
Person(String name,String post){
this.name = name;
this.post = post;
}
public String getID(){
return (name+""+post);
}
public abstract double counting();
public void setName(String name){
this.name = name;
}
public String getName(){
return this.name;
}
public void setPost(String post){
this.post = post;
}
public String getPost(){
return this.post;
}
}
class Leader extends Person{
Leader(String name,String post){
super(name,post);
}
public double counting(){
return 3000d;
}
}
class Management extends Person{
private double basicWage=0d; //基本工資
private double allowance=0d; //津貼
Management(String name,String post){
super(name,post);
}
public void setBasicWage(double basicWage){
this.basicWage = basicWage;
}
public double getBasicWage(){
return this.basicWage;
}
public void setAllowance(double allowance){
this.allowance = allowance;
}
public double getAllowance(){
return this.allowance;
}
public double counting(){
return this.basicWage+this.allowance;
}
}
class Teacher extends Person{
private int hours; //課時
static final double ASSISTANT_STANDARD = 35.0d;//助教的課時收費標準
static final double LECTOR_STANDARD = 45.0d;//講師的課時收費標準
static final double ANOTHER_STANDARD = 55.0d;//其他課時收費標準
Teacher (String name,String post){
super(name,post);
}
public double counting(){
double wage; //工資
if(this.getPost().equals("助教")){
wage = ASSISTANT_STANDARD*hours;
}else if(this.getPost().equals("講師")){
wage = LECTOR_STANDARD * hours;
}else{
wage = ANOTHER_STANDARD * hours;
}
return wage;
}
public void setHours(int hours){
this.hours = hours;
}
public int getHours(){
return this.hours;
}
}
class Test {
public static void main(String [] args){
Leader leader = new Leader("張三","領導");
System.out.println(leader.getName()+"工資為:"+leader.counting());
Management manage = new Management("李四","管理人員");
manage.setBasicWage(1000d);
manage.setAllowance(500d);
System.out.println(manage.getName()+"工資為:"+manage.counting());
Teacher teacher = new Teacher("王五","助教");
teacher.setHours(50);
System.out.println(teacher.getName()+"工資為:"+teacher.counting());
Teacher teacher1 = new Teacher("趙六","講師");
teacher1.setHours(60);
System.out.println(teacher1.getName()+"工資為:"+teacher1.counting
());
}
}
看下吧,有什么不足的請指出來
工資管理系統(tǒng)主要功能和特點:
1 操作簡單方便
采用國際流行的下拉菜單,全WINDOWS操作形式,界面新穎,全面支持鼠標操作,功能齊全。
2 任意設定工資項目
系統(tǒng)除姓名、人員編號、部門編號、部門名稱、應發(fā)工資、實發(fā)工資、納稅等內(nèi)定項目不能刪除(長度可以改變)外,其它項目(如各種補貼及各種扣款)均可由用戶自行定義(包括增加、刪除、修改長度及小數(shù)位等),工資項目總數(shù)可多達255項。當修改或刪除工資項目時,自動檢查工資計算中與該項目有關的計算公式,并作相應處理。
3 任意定義工資計算公式
用戶可將某些工資項目(如加班費、應發(fā)工資、納稅等)定義為計算項目,然后定義其計算公式及使用條件,可滿足各種復雜的計算。
如: 項目 公式 條件
每日工資 基本工資/26
月加班費 加班天數(shù)*每日工資 類別=
對數(shù)據(jù)庫進行增刪改查?
以下是 sql server 2013+java.實現(xiàn)的是對MSC對象的增刪改查.
需要下載連接驅(qū)動程序:com.microsoft.sqlserver.jdbc.SQLServerDriver
網(wǎng)上搜一下就行
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
class MSC
{
public String MscID;
public String MscName;
public String MscCompany;
public float MscLongitude;
public float MscLatitude;
public float MscAltitude;
public MSC(String MscID, String MscName, String MscCompany,
float MscLongitude, float MscLatitude,float MscAltitude){
this.MscID = MscID;
this.MscName = MscName;
this.MscCompany = MscCompany;
this.MscLongitude =MscLongitude;
this.MscLatitude = MscLatitude;
this.MscAltitude = MscAltitude;
}
}
public class sqlserverjdbc {
public Connection getConnection(){
String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; //加載JDBC驅(qū)動
String dbURL = "jdbc:sqlserver://localhost:1433; DatabaseName=gsm"; //連接服務器和數(shù)據(jù)庫sample
String userName = "sa"; //默認用戶名
String userPwd = "123"; //密碼
Connection dbConn = null;
try {
Class.forName(driverName);
dbConn =DriverManager.getConnection(dbURL, userName, userPwd);
} catch (Exception e) {
e.printStackTrace();
}
return dbConn;
}
public void printUserInfo(){
Connection con = getConnection();
Statement sta = null;
ResultSet rs = null;
System.out.println("打印表格MSC信息");
try {
sta = con.createStatement();
rs = sta.executeQuery("select * from MSC信息");
System.out.println("MscID\tMscName\tMscCompany\tMscLongitude\tMscLatitude\tMscAltitude");
while(rs.next()){
System.out.println(rs.getString("MscID")+"\t"+
rs.getString("MscName")+"\t"+
rs.getString("MscCompany")+"\t"+
rs.getFloat("MscLongitude")+"\t"+
rs.getFloat("MscLatitude")+"\t"+
rs.getFloat("MscAltitude"));
}
con.close();
sta.close();
rs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("打印完成\n");
}
public void delete(String MscID){
Connection con = getConnection();
String sql = "delete from MSC信息 where MscID = " + MscID;
PreparedStatement pst;
System.out.println("刪除表格MSC信息中 ID = "+MscID+"的記錄");
try {
pst = con.prepareStatement(sql);
pst.execute();
pst.close();
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("記錄刪除失?。。?!");
}
System.out.println("記錄刪除成功?。?!\n");
}
public void insert(MSC msc){
Connection con = getConnection();
String sql = "insert into MSC信息 values(?,?,?,?,?,?)";
PreparedStatement pst;
System.out.println("插入一條記錄");
try {
pst = con.prepareStatement(sql);
pst.setString(1, msc.MscID);
pst.setString(2, msc.MscName);
pst.setString(3, msc.MscCompany);
pst.setFloat(4, msc.MscLongitude);
pst.setFloat(5, msc.MscLatitude);
pst.setFloat(6, msc.MscAltitude);
pst.execute();
pst.close();
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("插入失敗?。?!");
}
System.out.println("插入成功?。?!\n");
}
//更新MscID的MscName
public void updateMscName(String MscID, String MscName){
Connection con = getConnection();
String sql = "update MSC信息 set MscName = ? where MscID = ?";
PreparedStatement pst;
System.out.println("修改一條記錄");
try {
pst = con.prepareStatement(sql);
pst.setString(1, MscName);
pst.setString(2, MscID);
pst.execute();
pst.close();
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("修改失?。。。?);
}
System.out.println("修改成功?。?!\n");
}
public static void main(String args[]){
sqlserverjdbc sql = new sqlserverjdbc();
sql.printUserInfo();
sql.delete("1111");
sql.printUserInfo();
sql.updateMscName("5215", "聯(lián)想");
sql.printUserInfo();
sql.insert(new MSC("1111", "中興" ," 中興", (float)12.2, (float)3.4,(float)45.5));
sql.printUserInfo();
}
}