CSE 110 Assignment 6 Fall 2015 Due Tuesday November 3

Cse 110 Assignment 6 Fall 2015due Tuesday November 3rd By 1000

Implement a class Employee with specified constructors and methods, including attributes for name, salary, and years of experience, and maintain a static count of employees. Include methods to access these attributes, modify the experience and salary, compare employees, and produce string representations. Create a test driver class to instantiate and manipulate Employee objects, replicating the provided sample interaction. Follow coding guidelines for naming, indentation, comments, and formatting as specified. Submit both Employee.java and Assignment6.java files online via the specified course platform by the deadline, ensuring they compile and run correctly.

Paper For Above instruction

The assignment revolves around creating a comprehensive Java class named Employee that embodies individual employee data and behaviors. This exercise emphasizes core Object-Oriented Programming (OOP) concepts such as encapsulation, constructors overloading, static variables, method implementation, and proper class design. Additionally, it involves the development of a test driver class, Assignment6, to interact with Employee objects, demonstrating their functionalities in a simulated user interaction scenario.

The central focus of Part 2 of this assignment is to implement a robust Employee class with a well-thought-out structure that adheres to specified specifications. The class must contain three private attributes: a String for the employee’s name, a double for the salary, and an int for the years of experience. Moreover, an internal static variable should keep track of the total number of Employee instances created, enabling the class to report how many employees have been instantiated at any time.

Constructors play a pivotal role in this class's design. The default constructor initializes all attributes to default values: name as "???", salary as 0.0, and experience as 0. It must also increment the static employee count. The parameterized constructor accepts explicit values for name, salary, and experience, setting the corresponding attributes. The third constructor accepts a formatted string, such as "Bond:70000:20", and, using string parsing methods, assigns the parsed values to the respective attributes, also increasing the employee count.

The class includes accessor methods such as getName(), getSalary(), and getYears() to retrieve these data. For getSalary(), formatting the output as currency (e.g., "$40,000.00") is required, which can be achieved via NumberFormat or similar classes in Java. These methods facilitate encapsulation and data hiding, providing controlled access to the internal attributes.

Mutator methods include setYears() to increment the experience years annually, and raiseSalary(double byPercent) to increase the salary by a given percentage. These methods modify the internal state responsibly, ensuring that the object maintains valid and consistent data.

Beyond basic getters and setters, more complex methods include makesMore(Employee x), which compares the salaries of two employees and returns the one earning more. The static method getNumEmployees() returns the total number of Employee instances, leveraging the static variable. The toString() method crafts a descriptive string encapsulating the employee's details, including the salary formatted as currency, and should be readily printable for debugging or display purposes.

The Assignment6 class acts as the test driver, prompting the user for employee details and providing a menu of commands as illustrated in the sample output. These commands include printing employee info, raising salaries, incrementing experience, comparing salaries to see who earns more, displaying the total number of employees, and quitting the program. The driver interprets user input and invokes corresponding Employee methods, showcasing their functionalities dynamically.

Following coding conventions, the Employee class code must be well-commented, with a header comment block containing author, filename, specification, class info, and time spent. Each method should have comments describing its purpose. The identifiers should be meaningful and consistent with the provided naming conventions, ensuring readability and maintainability.

Finally, submission involves uploading both Employee.java and Assignment6.java files to the course's online platform, verifying they compile and execute correctly, and following the formatting and commenting standards. No late submissions are accepted; multiple resubmissions are allowed before the deadline for students to improve their work.

References

  • Horstmann, C. S., & Budd, G. (2018). Core Java Volume I--Fundamentals. Prentice Hall.
  • Deitel, P. J., & Deitel, H. M. (2014). Java How to Program. Pearson.
  • Arnold, K., Gosling, J., & Holmes, D. (2005). The Java Programming Language. Addison-Wesley.
  • Liang, Y. D. (2012). Introduction to Java Programming and Data Structures. Pearson.
  • Bloch, J. (2018). Effective Java. Addison-Wesley.
  • Oracle. (2023). Java Platform, Standard Edition Security Developer's Guide. Oracle Documentation. https://docs.oracle.com/javase/8/docs/
  • Gosling, J., Joy, B., Steele, G., & Bracha, G. (2005). The Java Language Specification. Addison-Wesley.
  • Szarlata, J. (2017). Object-Oriented Programming with Java. McGraw-Hill.
  • Fowler, M. (1999). . Addison-Wesley.
  • Booch, G. (2007). Object-Oriented Analysis and Design with Applications. Addison-Wesley.