| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
long week, need a shove
G'day all,
it's been a long week of work and now i'm down to my last assignment. i'm not looking for the solution, just a design or some pseudocode points to go by. i want to just code the damn right without having to think about it. any help would be muuuch appreciated. thanks a bunch. here's the assignment You will have to implement a class that manages a singly linked list of SoldierNode objects storing information about soldiers. The SoldierList is always maintained sorted by the soldier’s rank and then the ‘number of kills’. Each SoldierNode object stores the rank, nickname, e-mail address, and number of kills of a soldier. Nickname and e-mail address are null-terminated character strings, and the number of kills is an integer. You must explicitly implement the linked list data structure. Sorting: Rank is determined by the ‘number of kills’ (>1000 = General, 500-999 = Captains, 1-500 = Soldiers, <1 = Trainee) Award: all generals receive a total share of 50% from the prize-money. Captains receive 30% while soldiers get 20%. The main operations (in the linked list) that are to be implemented include: · Insert – inserts a new soldier object in the correct place in the linked list. · SackLowest– returns the objects that have the lowest rank and then deletes them from the linked list. · MakeEmpty – delete all soldier-objects in the list · FindHighest– returns the objects that have the highest rank · Operator << - displays the list of soldiers. Your main program should perform the following operations. · First of all, get user’s input to select whether you are recruiting or sacking (hint: use numeric input 1 or 2). During recruiting: · Determine the number of new soldiers you want to recruit (1 to 5 only for each month) · Accept input from keyboard for the details of each soldier (nick name, e-mail address and number of kills) · Determine the rank of these soldiers and sort them properly in your SoldierList. · Display the current members of your SoldierList (sorted from highest rank) During award and sacking: · Get input for the prize-money that your squad wins for that month. · Get input for the number of kills that each soldier achieves during the month. Then update each soldier’s number of kills accordingly. For example, given that a soldier has 500 numbers of kills in the previous month (i.e. stored in the SoldierNode attribute), if that soldier earns –50 during the current month, it will be updated to 450. · Re-determine the rank of each soldier and then sort all soldiers accordingly. Finally, display the current squad in the new order. · Calculate the distribution of the prize-money (For example, given that there are 2 generals and the prize won in the month is $1000, each general would receive: ($1000*0.5)/2). · Display a summary of the award distribution. · Display and (then) remove all the soldiers whose rank is ‘Trainee’ Notes (you do not have to implement this): · During each game that your squad plays, number of kills is incremented by one (+1) every time a soldier can eliminate another soldier. However, each time that the soldier got eliminated, it will be decremented by one (-1). Format for input-output displays (blue-fonts are for examples only) What do you want to do? (1 for recruiting, 2 for award and sacking) Recruiting ------------ How many soldiers you want to recruit this month? (1-5 only) Soldier 1 – Nickname: Soldier 1 – E-mail address: Soldier 1 – Number of kills: Soldier 1 – Nickname: … (and so on) Current members of my squad (sorted by rank and number of kills): Rank Number of kills Nickname E-mail ------------------------------------------------------------------------- General 5000 Gunner gun@….. Captain 600 Machina machie@…. Award and Sacking ----------------------- Please enter the amount of prize-money your squad won this month: $______ Please enter the number of kills earned by each of your soldier (during this month): - Soldier 1 (Gunner): _____ - Soldier 2 (Machina): _____ Current members of my squad – after update (sorted by rank and number of kills): Rank Number of kills Nickname E-mail ------------------------------------------------------------------------- General 5000 Gunner gun@….. Captain 600 Machie machie@…. Summary of prize distribution Rank PrizeMoney Nickname E-mail ------------------------------------------------------------------------- General $5151 Gunner gun@….. Captain $1234 Machie machie@…. …… Soldier $150 Strongie strx@…. Trainees to be sacked: Nickname E-mail Number of kills ------------------------------------------------------- Riskie rsk@… -400 |
|
#2
|
||||
|
||||
|
Heh, that's a little much to bite off. We're better about addressing specific nagging problems than architecting (even in pseudocode) whole implementations like this.
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > long week, need a shove |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|