Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 28th, 2006, 05:29 PM
Registered User
 
Join Date: Jun 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Java is killing me!! Pls Help!!!!

I've been given this project and I'm honestly stuck. Somebody help me out. This is the project:

create a java application of an inventory that stores the names and departments of employees in an organisation and also the corresponding computers (use computer serial provided) that have been assigned them.

the application should run such that, it should take the employee name from keyboard and then produce the corresponding department and assigned computer of each employee.

the application should also calculate the total number of computers in each department and finally the total number of computers in the whole organisation.

store input items such as employee name, dept and assigned computers in excel or notepad.


NB: An interface is needed for the user of this application.


 
Old June 30th, 2006, 10:40 AM
Friend of Wrox
 
Join Date: Dec 2003
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

It sounds to me like you need to create an employee class which has getters and setters for name, department and computer. So

public class Employee {
   private String name;
   private Computer computer;

   // constructor
   public Employee (String newName, Computer newComputer) {
     setName(newName);
     setComputer(newComputer);
   };

   // getter methods
   public String getName(){ return name; };
   public String getComputer() { return computer;}

   // setter methods
   public void setName(String newName) {name = newName;}
   //etc.
}

You'll also want to write a Computer class, with getters and setters for the serial number.

You'll want to use these classes (when you've finished them off) from another class which has a collection of Employees and a collection of Computers - your Department class. Here's a snippet to help you with that:

int max=4; //max number of employees
Employee Emp[]=new Employee[max]; // array, size max of
                                  //Employee objects

// loop through Emp array and instantiate
// each employee object contained in it.
for(int i=0;i<max;i++) {
   String employeeName = "Employee #" + i; // replace with a sensible name!
   String serialNumber = "Computer #" + i;
   Emp[i]=new Employee(employeeName,new Computer(serialNumber));
}

Also give this a hasEmployee method, which returns true if an Employee is in your Emp[] Array. It'll also want a howManyComputers() method which will tell you how many computers the department has (the size of your computers array).

Finally, you'll want an Organization class, which has a collection of Departments and a main method which instantiates everything.

HTH charlie

--
Don't Stand on your head - you'll get footprints in your hair
                                           http://charlieharvey.org.uk
                                              http://charlieharvey.com
 
Old July 1st, 2006, 06:18 PM
Authorized User
 
Join Date: Jun 2006
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Cool the reply almost solved your problem

 
Old July 1st, 2006, 09:56 PM
Authorized User
 
Join Date: Jun 2006
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well me coding the whole project out ;)

 
Old July 27th, 2006, 01:43 PM
Registered User
 
Join Date: Jul 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to pulidot2000
Default

That above coding was just great! Hats off to you......

 
Old July 28th, 2006, 03:37 AM
Registered User
 
Join Date: Feb 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Very well! The structure is very clear!

 
Old September 2nd, 2006, 10:24 PM
Registered User
 
Join Date: Aug 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to hotleave
Default

Quote:
quote:Originally posted by pulidot2000
 That above coding was just great! Hats off to you......

i agree with you.

ÎÒÃǶ¼ÊǹÂÒíµÄÌìʹ
Ö»ÓÐÏ໥ӵ±§²ÅÄÜ·ÉÏè
 
Old September 24th, 2006, 10:29 PM
Registered User
 
Join Date: Sep 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to gebi1218 Send a message via AIM to gebi1218
Default

this project isn't difficult,i trust you will finish it:)






Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript started killing flash nairaby HTML Code Clinic 1 August 28th, 2007 11:47 PM
Java is KILLING me!!! I really need help!!!!! ironchef Java Basics 0 October 13th, 2006 09:45 PM
Datareader problem, killing me joer80 ADO.NET 1 March 23rd, 2006 06:44 PM
This is killing me RobCarter VB Databases Basics 1 January 18th, 2006 01:00 PM
i am new in java and JSP...pls help! frankiepoon JSP Basics 0 August 18th, 2003 08:51 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.