Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Really stressing with this java assignment

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Really stressing with this java assignment

    Hi im really stressing with this java assignment, I need to produce class diagrams/ sequence diagrams and the relevant code for the this scenario below can anyone help please!!!!!

    ” (CVF) company maintains a fleet of company vehicles, which it issues to certain employees who have to undertake deliveries and visit clients. The vehicles consist of both cars and trucks. Trucks are used to perform deliveries to clients and the cars are used to perform visits.

    At the moment the records of who has borrowed which vehicle are maintained using a very unreliable manual paper based system. A computerised system is required to keep a record of which vehicle has been lent to which employee and to maintain a record of the current state of the fleet and the personnel eligible to drive vehicles in the fleet.

    Currently, CVF records the following information on each of its vehicles: Registration number, make, model and drive-class. In addition, cars have the total number of seats they have and trucks the maximum load they can carry recorded. The drive-class value is either a 1 or 2 depending on whether the vehicle is a car or truck. Employees have their employee number, name and drive-class recorded. Once again the drive-class is a value of 1 or 2. The drive-class attribute is used to determine whether an employee is allowed to drive a particular vehicle. An employee with a drive-class of 1 is only allowed to borrow cars. An employee with a drive-class of 2 is allowed to borrow both cars and trucks. An employee is only allowed to borrow one car at a time and also a vehicle can only be allocated to a single employee at a time.

    The company currently has the following vehicles in its fleet.

    Veh.Reg# Make Model Drive-Class Seats/MaxLoad
    10001 Mazda 323F 1 5
    10002 Ford Escort 1 5
    10003 Ford Transit Van 2 100
    10004 Mazda 60E 2 500
    10005 Citroen Saxo 1 5
    10006 MG MGF 1 2
    10007 Mercedes 600 2 500
    10008 Volvo V70 1 5
    10009 Volkswagon Golf 1 5
    10010 Volvo Trooper 2 250

    The company currently has the following employees, all of whom can drive vehicles according to their allocated drive-class.

    Emp # Name Drive-Class
    201 Nero Eoghan 2
    202 Eirenaios Vulcan 2
    203 Nuada Glaucus 1
    204 Drest Aldo 1
    205 Waldo Aodh 1
    206 Dardanos Felix 2
    207 Odovacar Phoebus 1
    208 Myrddin Onesimos 2
    209 Randulf Severus 2
    210 Wolfgang Alboin 1


    The system you have to design and implement should ensure that only valid allocations could be made, i.e. one vehicle to one employee and only to employees of the correct drive-class. The information should be stored in a file.

    The system must be able to handle the following use cases:

    1. Borrowing vehicles from the fleet
    2. Returning vehicles to the fleet
    3. Adding a new vehicle to the fleet
    4. Deleting a vehicle from the fleet
    5. Displaying all vehicles' details in the fleet
    6. Displaying all employee details


    Your tasks
    1. Specify your functional and testing requirements based on these use cases.
    2. Define a top-level design for your program, using UML to document it.
    3. Design and document the appropriate classes for the application.
    4. Construct a working application.
    5. Test it.
    6. Deliver it.


    The following section provides guidance as to where marks can be allocated:


    Design [30 marks]

    Model the above scenario using the object-oriented approach and produce appropriate documentation for the model, which must include the following:
    • Overview of your architecture and design
    • Structural and behavioral diagrams
    o a) Class /Association diagram(s)
    o b) Object sequence diagram(s)
    • Written descriptions of each class
    • Any necessary algorithm documentation (NS diagrams, PDL, flow charts, or similar)
    • Provide explanations and justifications where appropriate. Make reasonable assumptions when necessary. These should be fully explained and justified.
    • Critical discussion as to how the design/program you have developed exploits polymorphism to simplify the object-oriented implementation of your solution. This discussion must draw upon examples taken from your work on this project.

    Programming [40 marks]

    Depending on whether most of the project requirements are met, or all requirements are met., here are the mark allocations:
    1. Borrowing vehicles from the fleet (5%)
    2. Returning vehicles t the fleet (5%)
    3. Adding a new vehicle to the fleet (5%)
    4. Deleting a vehicle from the fleet (5%)
    5. Displaying all vehicles' details in the fleet (5%)
    6. Displaying all employee details (5%)

    • Successful compilation of a program designed to meet the project requirements by the Java 1.5 SDK.
    • Marks for good object-oriented design and for effective and complete use of comments and appropriate names in the code.
    • Successful execution of the program in that environment.
    Make any reasonable assumptions if necessary. You do not have to implement any classes that are not required to provide the functionality listed above.

    Can someone help me please!!!!


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Really stressing with this java assignment

    Sorry, but we won't do your homework for you.

    Can you show what work you've done so far and what specifically you need help with? If you're getting an error message, please post it in full.

  3. #3
    Junior Member
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Really stressing with this java assignment

    Hi im provided with this very rough code
    package sm19028;
     
    //import java.util.ArrayList;
    import java.util.ArrayList;
    import java.util.Scanner;
     
    public class CardiffVehicleFleet {
     
    	//fields
    	private ArrayList vehicleList;
    	private ArrayList clientList;
     
    	public CardiffVehicleFleet() {
    		 vehicleList= new ArrayList();
    		 clientList= new ArrayList();
     
     
    	}
     
     
     
     
     
     
     
     
    	public void AddVehicle()
    	{
     
     
     
    		Vehicle v1 = new Vehicle("A1 Car","E-type jag");
    		Vehicle v2 = new Vehicle("CE60 EBB","Mercedes");
    		Vehicle v3 = new Vehicle("aaaaaaaaa","Mercedes");
    		Vehicle v4 = new Vehicle("bbbbbbbbb","Mercedes");
     
    		vehicleList.add(v1);
    		vehicleList.add(v2);
    		vehicleList.add(v3);
    		vehicleList.add(v4);
    		vehicleList.add(v4);
     
    		vehicleList.add( new Vehicle("bbbbbbbbb","Mercedes") );
    		vehicleList.add( new Vehicle("bbbbbbbbb","Mercedes") );
    		vehicleList.add( new Vehicle("bbbbbbbbb","Mercedes") );
    		vehicleList.add( new Vehicle("bbbbbbbbb","Mercedes") );
    		vehicleList.add( new Vehicle("bbbbbbbbb","Mercedes") );
     
    		for(int i=0; i < vehicleList.size(); i++)
    		{
    			//System.out.println();
    					String s = ((Vehicle)vehicleList.get(i)).getRegistrationNumber();
    					System.out.println(s);
    		}
     
     
     
     
    	}
     
     
     
    	public void DisplayAllVehicles()
    	{
     
     
    		return;
    	}
     
     
    	public void SaveVehiclesToFile()
    	{
     
     
    		return;
    	}
     
    	public int Menu()
    	{
    		//1.	Display all current vehicles
    		//2.	Add/ delete vehicles to the fleet
    		//3.	Save vehicles to file
    		//4.    Exit
     
    		System.out.println("Please Make a selection:"); 
            System.out.println("[1] Display all current vehicles"); 
            System.out.println("[2] Add/ delete vehicles to the fleet"); 
            System.out.println("[3] Save vehicles to file"); 
            System.out.println("[4] exit"); 
            System.out.println("Selection: "); 
     
     
            String name;
            int selection;
            Scanner in = new Scanner(System.in);
     
            // Reads a single line from the console 
            // and stores into name variable
            name = in.nextLine();
     
            // Reads a integer from the console
            // and stores into age variable
            selection=in.nextInt();
            in.close();               
     
           switch (selection){
     
               case 1:System.out.println("Display all current vehicles");
               		DisplayAllVehicles();
     
                    break;
     
     
               case 2:System.out.println("Add/ delete vehicles to the fleet");
     
     
                    break;
     
     
               case 3:System.out.println("Save vehicles to file");
     
               		SaveVehiclesToFile();
     
                    //System.exit(0);
               		break;
     
               case 4:System.out.println("Exit Successful");
     
     
              System.exit(0);
               //break;
     
               default:System.out.println("Please enter a valid selection.");
     
           };
     
     
            return selection;
        }
     
     
     
     
     
     
    	public static void main(String[] args) {
     
    		//Vehicle v1 = new Vehicle("CE60 EBB","E-type jag");
    		//System.out.println(v1.getRegistrationNumber());
     
     
     
    		// MENU
    		CardiffVehicleFleet cvf = new CardiffVehicleFleet();
     
     
    		cvf.AddVehicle();
    		//for(int i =0; i<1000; i++)
    			//cvf.Menu();
     
     
     
     
     
     
     
    	}
     
    }
    I don't know how to run this to see if it works though :/
    Last edited by helloworld922; December 5th, 2010 at 05:26 PM.

  4. #4
    Junior Member
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Really stressing with this java assignment

    What do you mean by you dont know how to run? javac sourcefile and java classfile.
    Anyway, i am seeing a lot of problems with your codes.
    I'll briefly point on a couple, but not all.

    if you want to add a vehicle to your fleet, you should let the clerk(whoever using the software) to define what vehicle to add. That means you need to create a vehicle object based on user description and give this vehicle object to your AddVehicle method.

    So your AddVehicle method should look something like this.
    public void AddVehicle(Vehicle x){
         vehicleList.add(x);
    }
    All you then need to do is to use a loop and let user enter as make vehicles as they want, make sense?

    Next when defining object classes, i am pretty sure your prof have taught you toString() method at the beginning of your class. define your toString() method for Vehicle class. It will very easily help you to accomplish your DisplayAllVehicles() and SaveVehiclesToFile() methods.

  5. #5
    Junior Member
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Really stressing with this java assignment

    How do i create a menu so that I can add/delete when i compile and run this code, it displays in the eclipse console some cars which is added.

Similar Threads

  1. my java assignment -- please help
    By java_beginner in forum Java Theory & Questions
    Replies: 6
    Last Post: May 20th, 2010, 08:32 AM
  2. Replies: 1
    Last Post: February 22nd, 2010, 08:20 AM
  3. Beginner needs help with simple java assignment.
    By joachim89 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 6th, 2010, 07:53 PM
  4. I need extensive help with my java assignment
    By MoshMoakes in forum What's Wrong With My Code?
    Replies: 0
    Last Post: December 12th, 2009, 07:44 PM
  5. [SOLVED] Problem with Grading calculator in java program
    By Peetah05 in forum What's Wrong With My Code?
    Replies: 23
    Last Post: March 28th, 2009, 04:25 PM