Hey guys, I have started java for a uni class. I am now using object oriented programming. I have taken vb so i know what functions/methods are. however i am having a hard time coding some programs for an assignment. I will try to make this thread as descriptive as possible so you can help me better. The text book i am using is murach's java se 6. its a pretty good book, but i am lost in this object oriented and methods part. i do not know how to have user input from one class passed through to another class. The link to the asignment is here. However i am not asking for someone to do the assignment. I am asking for help on how to pass variables and how/where to make the object. I really want to learn this so im not asking for a written program. I've attached a flow diagram that i used to map out how i think the program will work. i have attached my code so that you can see where i have lost my train of thought, or gone wrong. thank you in advance

I'm just gone give you example how this work with little different topic

public class Employee {
	
	private int empNum;
	private String firstName;
	private String lastName;
	private String department;

    public Employee(int empNum, String firstName, String lastName, String department) {
    	setEmployeeNumber(empNum);
    	setFirstName(firstName);
    	setLastName(lastName);
    	setDepartment(department);
    }
    
    private void setEmployeeNumber(int empNum){ this.empNum = empNum; }
    public int getEmployeeNumber(){ return empNum;}
    
    private void setFirstName(String firstName){ this.firstName = firstName;}
    public String getFirstName(){ return firstName;}
    
    private void setLastName(String lastName){ this.lastName = lastName;}
    public String getLastName(){ return lastName;}
    
    private void setDepartment(String department){ this.department = department;}
    public String getDepartment(){ return department;}
    
    public void employeeToString(){
    	System.out.printf("%05d\t %s\t\t %s\t\t %s\n", 
    		getEmployeeNumber(), getFirstName(), getLastName(), getDepartment());
    }
}
public class EmployeeTest {

    public static void main(String[] args){
    	Employee[] e = new Employee[3];
    	e[0] = new Employee(123, "Mickey", "Mouse", "IT support");
    	e[1] = new Employee(234, "Scrooge", "McDuck", "Finance");
    	e[2] = new Employee(345, "Donald", "Duck", "Research");
    	
    	for(Employee emp :e){
    		emp.employeeToString();
    	}
    }    
}

thanks for your help, i was able to get the help of the clas Ta, and i finished the first part of the assignment (the circle one). I am having trouble with the dice program though, i'm trying to model it in my brain using the same way i did with the circle program, but i am having trouble, what am i doing wrong or would you say not understanding?

So i think i found a way to clarify what i'm having trouble with. Based on the info the teacher has given with the methods and constructors i don't know from which class to call which method and where each part of code should, as well as how much of the code to put in one place (eg i could probably just stick all the code in one place but he wants us to learn encapsulation)

write a program that will accept an integer number from 0-9999. Then, convert this number into words

write a program that will accept an integer number from 0-9999. Then, convert this number into words

Start a new thread

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.