Uni Programing Help

robmiller said:
Well done for being able to inaccurately translate pseudocode to Java though... bleedin' first-year computer science students think they know it all *grumble*
Interesting, as I just compared the output from that java to a list of leap years, they seem to be the same. Where's the innacuracy?

Hmm, almost an exact copy of what I posted is given in K&R II (and I didn't know it beforehand).

krleapdg9.jpg

must be you second years.
 
Last edited:
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!
 
Phnom_Penh said:
must be you second years.

I'm a first year I just don't take rubbish subjects sorry

Anyway, your original post was:

Code:
if(((year % 4 == 0)&(year % 100 != 0))|(year % 400 == 0))

which is not what the pseudocode or K&R say at all.
 
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
 
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;
}
 
Last edited:
robmiller said:
I'm a first year I just don't take rubbish subjects sorry

Anyway, your original post was:

Code:
if(((year % 4 == 0)&(year % 100 != 0))|(year % 400 == 0))

which is not what the pseudocode or K&R say at all.
I do war history and politics, why's that rubbish? :confused:
It's exactly what both say, unless you can somehow prove otherwise.
 
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
 
Sure its just polymorphism, but really I wouldn't worry about that till you master the basics. Interfaces also define a type.
 
Last edited:
jcb33 said:
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
But item would be a type as when you define your item class really you are defining a type called item, that has some data associated with it and has a set of methods that you can call on it.
 
robmiller said:
Since when have bitwise operators been the same as boolean operators?
Bitwise is boolean. I know you're refering to the use of bitwise operators in that code. In this case they function the same. They were however changed to logical operators a few posts in.
 
Back
Top Bottom