Uni Programing Help

DaveF said:
You start the loop with counter = month (yes, you've replaced 'month' with counter2, but counter2 = month, so it doesn't make any difference), and the loop condition is to stop as soon as (counter<month) is false. Does it really surprise you that the loop doesn't do anything?

You really need to read up on the syntax for a for() loop. To be honest, I find it shocking that you could get almost 57 percent for your last coursework and be coming up with code this poor.
You know, no need to be rude, for a start its my first year, and the programing we are learning is very basic, and for a second its very easy to make a mistake and not spot it!

Code:
int counter1 = monthBirth+1;
        int counter2 = month+1;
        
        for(int counter=counter1;counter<month;counter++){
            counter1++;
            monthTotal = monthTotal+daysInMonth[counter1];
            
        }        
        for(int counter=counter2;counter<monthBirth;counter++){
            System.out.println(counter);
            counter++;
            monthTotalFinal = monthTotalFinal+daysInMonth[counter2];
        }

Is what I now have, but still does not return the correct value, may end up going with the 24 if statements after all...
 
MrWhippy said:
this thread wouldn't have got anywhere near as many posts had it been posted in the right section.

scrap "HTML, Graphics & Programming" i say :)
Meh I find HTML Extremly easy, as for Graphics, not done them yet so I cant say, and no I wont give up on Programing, Im not letting it beat the j! It may take time but I shall master it!
 
Well I have given up on the for loops, and gone with 24 if statements, it may look a mess, but as you say its my first year and im here to learn how to be a student, and how to learn!

Im getting programing much more than I was at the start of the year, hell I found it hard to make a helloworld program to begin with, now I can get programs running fine, I just feel that my if statements (Well actualy I know) can be done in a much neater, less space intensive manner!
 
I have just made a UML Diagram for the following:

In a computer game, clans are made up of a set of players. Each clan has a name, a flag, a store containing clan items and some cash. Each player has a name, an experience score, and a collection of items (weapons, armour, etc). Produce a UML class diagram showing these classes and their relationships.

Is it at all correct? Never made one before :)

UML.JPG
 
robmiller said:
Your types seem a bit... weird :/

I would expect getItemInfo to return an Item, getClanName to return a string, etc., and then wouldn't Clan.Name be more useful as a string?

Also, it would probably be best to have an Item class, with "items" being a collection of instances of said class, so you'd have something like (C#, but I'm sure you can translate to Java—I'm not familiar with generics in Java, sorry):

Code:
Clan clan = new Clan("Witty Clan Name");

clan.Items = new List<Item>();

clan.Items.Add(new Item("Gun"));
clan.Items.Add(new Item("Grenade"));

Although items themselves would probably be better as structs, eg

Code:
public struct Gun {
    public string Name = "Gun";
    public float Value = 2500.00;
}

public struct Grenade {
    public string Name = "Grenade";
    public float Value = 400.00;
}


Well AFAIK I dont need to make the actualy items as I dont have much info to go on. Also can you have the word Item in UML? As this does not represent a type.... well not that I know
 
Back
Top Bottom