Not so last min, last min uni work, Programing and UML

Soldato
Joined
11 Apr 2003
Posts
4,208
Location
Notts
Hi all, I have an assignment due for programing (again) and I have done very little work on UML Diagrams, My first 2 tasks are:

1) A UML use-case diagram for the system, including all important actors
who will use the system. You should also include a short commentary
on this diagram, describing the process that you used to develop the
diagram. [17%]

2) A UML class diagram, including appropriate methods and attributes
for each class in the system. Again, a commentary on your design
process should be handed in too. [16%]

The problem I have is this:

Code:
Fitzroy Bailey, the owner of Rockall Vehicle Rental Agency, wishes to set up
a stock-control system to manage hiring, invoicing, and customer records.
Bailey should be able to determine how many vehicles are on hire at a given
moment, and what the rental income to date is. The shop hires bicycles by
the half-day, cars by the week (with an additional charge if a car is used
for more than an average of 1,000 miles/week), and helicopters by the hour.
When a customer hires a vehicle, an employee must record their name and
address, and ensure that the hiring information is recorded, including the
length of time for which the vehicle has been hired. Everyone who hires a
vehicle must pay for it at the time of hiring.

Would this Use case diagram for the problem be correct?

use_Case.JPG


“A customer rents a vehicle”. This is related to both the customer, who wishes to rent, and the employee who must arrange the rental. The employee will perform a “check on the customers rental history” to see if he or she is will be loaned a vehicle, this action extends the “Rent vehicle” use case.

Once it has been decided that the customer will rent a vehicle, the action of renting the vehicle includes two actions,” invoicing the customer” for the cost of the rental (getting payment) and making sure they have what the “stock” the customer wants.

The customer also needs to “return the vehicle”, the employee again deals with this, the process of returning the vehicle included “checking how long the vehicle was out” and “issuing any extra costs” resulting in extended rentals, this will also be added to the “customers records”.

The employee will update all of the “customers records”, with details such as current rentals, reliability, return times etc. Finally the shop (or boss) will deal with hiring, and firing of staff, meaning they relate to the employee, they will also have a copy of the customer records, and be responsible for preparing the customer invoices.
 
Last edited:
Hows This?

usecase2.JPG


A customer, can “rent” or “return” a vehicle from the shop, each time they come in their record will be accessed, “if” they are a new customer, then a new record will be added.

If they are returning then the system will check if they returned the vehicle on time, it will also check its mileage if it is a car, and “if” need be an additional bill will be issued to the customer.

When the customer is renting, then first stock will be checked, and if the vehicle they want is in stock they will be invoiced/billed.

The employee is in charge of managing the customers records, adding additional information etc.

The shop manages the hiring of staff.

Need to make sure I have covered:

Code:
Identification of all major use cases, with clear justification
 
Last edited:
Also is this class diagram ok?

classdiagram.JPG


Shop accesses vehicle information and customer records. It stores the dates, and times in which vehicles are rented and returned, it also finds out if what the customer wants is in stock, and issues them with invoices.

Customer records holds information on the customer, their name, address and if they are currently renting anything, it also deals with rent requests and rent returns.

Vehicle stores information on the vehicles currently in stock, car, bicycle and helicopter, it finds out the mileage (If a car) and the rental duration. It also gets the cost of renting the vehicle for the set amount of time.

Need to make sure I have covered:

Code:
Correct usage of methods and attributes and relationships between classes, good narrative description

Code:
Show inheritance on class diagram
 
Last edited:
Amoeba said:
Why do you have cost and maximumRentalTime in your Vehicle subclasses, and not in Vehicle itself?
Because the cost of each vheicle is different, as is the amount of time each vheicle can be rented?
 
Im trying to make ths system, so I can

Find existing customers
Add new customers and assign them a customer number

Just wondering, how can I make it so the system search customer numbers, and if it finds them it fetches the details, else returns an error message, else I would have to program in each new customer, rather than letting new ones be input
 
So esentialy, I can create a new object, and store in my values e.g

Customer new = new Customer(address,phoneNumber);

and each time I run this I could add it automaticaly to a hashmap, so say the first time I run, customer number = 1, second, 2 etc?

Also what is the best way to represent an address? I have never done anything that involves anything but a number, so I have no idea how to make java accept and store say 30, Land Road, England, NGR 443...
 
Some reason it wont accept .put, and I had to alter quite abit of the code for it to compile
 
Last edited:
Phil99 said:
Strange, I just copy and pasted that in to notepad and used javac/java instead of Netbeans and it compiled/ran fine :confused:

Which bits did you have to alter?

Well so far I have this:

Code:
import java.util.HashMap;

public class Test {
    
    int id;
    String name;
    
    /** Creates a new instance of Main */
    public Test(int id, String name) {
        this.id = id;
        this.name = name;
    }
    
    public int getID() {
        return id;
    }
    
    public String getName() {
        return name;
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        HashMap hashmap = new HashMap();
        Test test = new Test(1,"Food Is Yummy"); 
        Test test2 = new Test(2,"You Suck");
        

        hashmap.put(test.getID());
        
        System.out.println(hashmap.get(1).getName());
        System.out.println(hashmap.get(2).getName());
        System.out.println(hashmap.get(1).getName());
    }
}

Im using BlueJ To compile and atm its returning cannot resolve symbol - metod put(int)
 
Phil99 said:
Looks like you forgot to tell the HashMap what types of variables to expect (look up Generics for more info)

Code:
HashMap[b]<Integer,Test>[/b] hashmap = new HashMap[b]<Integer,Test>[/b]();

You also need to pass the object you want to be stored with relation to the key you're supplying to the put() method as well otherwise you're just trying to store a key with nothing actually linked to it.

The bits in the < > tell it what to expect; the first (Integer) is the type of object the key should be and the second is the type the value you want it to return when you look up the key should be.

With the HashMap above the method signature for the put method in the HashMap object would look something like this:

Code:
public void put(int key, Test value)

If that helps to explain it at all.

The API explains more: http://java.sun.com/j2se/1.4.2/docs/api/java/util/HashMap.html
Yes, but HashMap<Integer,Test> hashmap = new HashMap<Integer,Test>(); = error: Not a statement
 
Una said:
Thats the correct syntax where abouts are you defining it?

Generics was only added to java 1.5... if you have version <1.5 it won't work and stop using blue-j it's bloody horrible :p

Well I would stop using it, but uni seem to love it
 
Amoeba said:
The only way I can think of to make it add an auto increment ID to each object, is to keep an int in your control class which keeps the most recently generated id, and then each time you create a new CustomerRecord instance pass the value of this int plus 1 to the constructor.

With regards to your address, it is totally up to you. You could store the whole thing as a String, or create a new Address class which had fields like
Code:
int number;
String road;
String town;
String county;
String postcode;
etc, and then store a reference to an Address instance in your CustomerRecord instance. I would be tempted to do it the second way, as then you could do searches on the customer database based on specifics of the address.

Lastly, as already suggested it seems as though you may be using JDK 1.4.2 or lower. To use Generics (the <Integer, Test> bit) you need 1.5 or above :)
Thanks, will try to get the latest java tomorow (Bed early as work in morning) and im not sure that searching the database will be an issue, as I have no idea how to do that at all, and we have not even discused this in lectures workshops :eek: Whats even more scary is we are going from basic java this year, to programing graphics in C++ next year, and thats things like how light reflects off a surface :/
 
Amoeba said:
Even if you don't need to perform searches etc now, it's always best to plan ahead! Plus it may get you extra marks if you have a nice OO design, and have planned extensibility :).
Could I be cheeky and ask you if you would mind looking over what I have done, and letting me know if its correct? Have just for now created a system that can have one of each vehicle, and 1 customer at any one time
 
Thanks, have sent you the files in a rar file to the email in your trust :) Should be 32kb

*EDIT* Well as that did not work, I have uploaded it to my host and will email you the link, said your email blacklisted me for sending a rar file!
 
Last edited:
Just incase you already downloaded it from the link I sent you, I have updated it since then, its not yet commented though, gonna be doing that today (I know I should comment as I go but I find it easier to do it after I finish)
 
Phil99 said:
Why not post it up on here? This is a forum, not jcb33's personal help pages. It might be beneficial for other people to see what people are doing to the code to further their knowledge of it as well :)
Dont be rude :p, The reason im not posting it, as noted before, there are other people from my uni that use these forums, and the uni searches the net for code, so if i post my code, they could find it and say I plagerised myself...

I am quite happy however to post code from my other assignments :)
 
5ingh said:
You are already plagerising by posting up your diagrams and asking for 'more' than help :)
Depends how you define plagerism, my diagrams have changed since then (As my program looked nothing like them) And I have not copied anything from this topic, wrote my hole program alone actualy, wheter its done right or not thought is another kettle of fish :eek:
 
Back
Top Bottom