how to Create a Java Package from MATLAB Code?

Java Programming Challenge Employee.java?

  • I need help: Employee.java: This class contains all the information about a single employee. Create either a no argument constructor or an overloaded constructor. Include accesor/mutator methods for the class attributes. Code a toString method. Assignment03.java This class tests the Employee class. This class does not request any input from the user in this application. Create 3 Employee objects and populate them with data. Print out the details of 2 of the 3 objects using the toString method. Print the 3rd Employee object using the accessor methods for the class. Here is the code i got so far below and i cant get it to compile or work together as one project. I am using Netbeans: EMPLOYEE.JAVA public class Employee { private String employeeName; private String employeeNo; private String departmentCode; private String positionCode; public Employee( String name, String no, String dc, String pc ) { employeeName = name; employeeNo = no; departmentCode = dc; positionCode = pc; } public void setEmployeeName( String name ) { employeeName = name; } public String getEmployeeName() { return employeeName; } public void setEmployeeNo( String no ) { employeeNo = no; } public String getEmployeeNo() { return employeeNo; } public void setDepartmentCode( String dc ) { departmentCode = dc; } public String getDepartmentCode() { return departmentCode; } public void setPositionCode (String pc) { positionCode = pc; } public String getPositionCode() { return positionCode; } } public String getdata() { return String.format( "Employee Name: %s\nEmployee No.: %s\nDepartment Code: %s", getEmployeeName(), getEmployeeNo(), getDepartmentCode() getPositionCode()); (ERROR ON THIS LINE) } ASSIGNMENT03.JAVA /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package employee; /** * * @author F739WM */ public class Assignment03 { public static void main(String[] args) { // Create three instances of the Employee class. employee employee1 = new employee(); employee employee2 = new employee(); employee employee3 = new employee(); // Store data for the first employee. employee1.setName("Susan Meyers"); employee1.setIdNumber(47899); employee1.setDepartment("Accounting"); employee1.setPosition("Vice President"); // Store data for the second employee. employee2.setName("Mark Jones"); employee2.setIdNumber(39119); employee2.setDepartment("IT"); employee2.setPosition("Programmer"); // Store data for the third employee. employee3.setName("Joy Rogers"); employee3.setIdNumber(81774); employee3.setDepartment("Manufacturing")… employee3.setPosition("Engineer"); // Display the data for employee 1. System.out.println("Employee #1"); System.out.println("Name: " + employee1.getName()); System.out.println("ID Number: " + employee1.getIdNumber()); System.out.println("Department: " + employee1.getDepartment()); System.out.println("Position: " + employee1.getPosition()); System.out.println(); // Display the data for employee 2. System.out.println("Employee #2"); System.out.println("Name: " + employee2.getName()); System.out.println("ID Number: " + employee2.getIdNumber()); System.out.println("Department: " + employee2.getDepartment()); System.out.println("Position: " + employee2.getPosition()); System.out.println(); // Display the data for employee 3. System.out.println("Employee #3"); System.out.println("Name: " + employee3.getName()); System.out.println("ID Number: " + employee3.getIdNumber()); System.out.println("Department: " + employee3.getDepartment()); System.out.println("Position: " + employee3.getPosition()); System.out.println(); } } } On this coding program, i get errors with the "set" coding. Please help anyone?? Not asking for someone to do my assignment for me, as you can tell, i have done the programs myself, just stuck.

  • Answer:

    You likely need to start by naming the files to match the classes, and I believe that case matters. The file containing the Employee class should be "Employee.java". The file containing the Assignment03 class should be "Assignment03.java". The variables of type Employee should be "Employee" rather than "employee". Also, I notice that Assignment03 is part of the package employee, but the Employee class is not. Fix those things, and then see what else you run into.

db at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

You R also declaring your objects as employee and you class is written with capital "E", Also try writing a default constructor like public Employee(){ }

Easy, you're using two different names for the same member function. You have defined Employee.setEmployeeName(), but you are calling Employee.setName(). The latter doesn't exist.I suggest changing the declaration of setEmployeeName() to be setName() - and all the similarly named functions - and all will be well.

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.