【cisp401系列PayrollApp.java版本】出门莫恨无人随,书中车马多如簇。这篇文章主要讲述cisp401系列PayrollApp.java版本相关的知识,希望能为你提供帮助。
- import java.io.*;
- public class PayrollApp {
- // Data Objects (
- private Employees empTable;
- private static final MyString REPORT_HEADER_A = new MyString( " EmployeePayHoursGrossTaxNet" ) ;
- private static final MyString REPORT_HEADER_B = new MyString( " NameRateWorkedPayAmountPay" ) ;
- private static final MyString REPORT_HEADER_C = new MyString( " ====================== ======== ========== ========== ========== ==========" ) ;
- private static final MyString WORD_TOTALS = new MyString( " Totals:" ) ;
- private static final MyString WORD_AVERAGES = new MyString( " Averages:" ) ;
- //)
- // Constructors (
- public PayrollApp( ) {
- empTable = new Employees( ) ;
- }
- public PayrollApp( HourlyEmployee e) {
- empTable = new Employees( e) ;
- }
- public PayrollApp( PiecedEmployee e) {
- empTable = new Employees( e) ;
- }
- public PayrollApp( SalariedEmployee e) {
- empTable = new Employees( e) ;
- }
- public PayrollApp( Employees e) {
- empTable = e;
- }
- public PayrollApp( File file) {
- empTable = new Employees( file) ;
- }
- //)
- // Accessors (
- public Employees getEmps( ) {
- return new Employees( empTable) ;
- }
- //)
- // Mutators (
- public MyString tableHeader( ) {
- return new MyString( " " + REPORT_HEADER_A + " " + REPORT_HEADER_B + " " + REPORT_HEADER_C) ;
- }
- public MyString[ ] tableRows( ) {
- MyString[ ] rows = new MyString[ empTable.size( ) ] ;
- for ( int i=0; i< empTable.size( ) ; i++) {
- HourlyEmployee e = ( HourlyEmployee) empTable.employee( i) ;
- rows[ i] = new MyString( " " + e.formattedName( ) .left( 22) + " " + e.payRate( ) .myString( 2) .right( 8) + " " + e.hours( ) .myString( 2) .right( 10) + " " + e.grossPay( ) .myString( 2) .right( 10) + " " + e.taxAmount( ) .myString( 2) .right( 10) + " " + e.netPay( ) .myString( 2) .right( 10) ) ;
- }
- return rows;
- }
- public Number totalPayRate( ) {
- Number total = new Number( ) ;
- for ( int i=0; i< empTable.size( ) ; i++) {
- total = total .plus ( ( ( HourlyEmployee) empTable.employee( i) ) .payRate( ) ) ;
- }
- return total;
- }
- public Number totalHours( ) {
- Number total = new Number( ) ;
- for ( int i=0; i< empTable.size( ) ; i++) {
- total = total .plus ( ( ( HourlyEmployee) empTable.employee( i) ) .hours( ) ) ;
- }
- return total;
- }
- public Number totalGross( ) {
- Number total = new Number( ) ;
- for ( int i=0; i< empTable.size( ) ; i++) {
- total = total .plus ( empTable.employee( i) .grossPay( ) ) ;
- }
- return total;
- }
- public Number totalTax( ) {
- Number total = new Number( ) ;
- for ( int i=0; i< empTable.size( ) ; i++) {
- total = total .plus ( empTable.employee( i) .taxAmount( ) ) ;
- }
- return total;
- }
- public Number totalNet( ) {
- Number total = new Number( ) ;
- for ( int i=0; i< empTable.size( ) ; i++) {
- total = total .plus ( empTable.employee( i) .netPay( ) ) ;
- }
- return total;
- }
- public Number avgPayRate( ) {
- return totalPayRate( ) .over ( empTable.size( ) ) ;
- }
- public Number avgHours( ) {
- return totalHours( ) .over ( empTable.size( ) ) ;
- }
- public Number avgGross( ) {
- return totalGross( ) .over ( empTable.size( ) ) ;
- }
- public Number avgTax( ) {
- return totalTax( ) .over ( empTable.size( ) ) ;
- }
- public Number avgNet( ) {
- return totalNet( ) .over ( empTable.size( ) ) ;
- }
- public MyString totalsRow( ) {
- return new MyString( " " + WORD_TOTALS.left( 22) + " " + totalPayRate( ) .myString( 2) .right( 8) + " " + totalHours( ) .myString( 2) .right( 10) + " " + totalGross( ) .myString( 2) .right( 10) + " " + totalTax( ) .myString( 2) .right( 10) + " " + totalNet( ) .myString( 2) .right( 10) ) ;
- }
- public MyString averagesRow( ) {
- return new MyString( " " + WORD_AVERAGES.left( 22) + " " + avgPayRate( ) .myString( 2) .right( 8) + " " + avgHours( ) .myString( 2) .right( 10) + " " + avgGross( ) .myString( 2) .right( 10) + " " + avgTax( ) .myString( 2) .right( 10) + " " + avgNet( ) .myString( 2) .right( 10) ) ;
- }
- //)
- }
推荐阅读
- Android获取IP地址
- 退出ANDROID应用程序AIR
- 禁用包含apple内容的网页=/
- 创建android项目
- 使用datamapper启动Rails项目
- Android pull解析器示例
- Android文本视图
- 允许在外部设备上安装android应用程序
- 使用launchdlaunch agents和launchctl,Apple Mac OSX Plist可实现更好的文件夹操作