Hi, I need help with a school project the question is as follows:
In this assignment you will be writing programs to manage tables containing league standings in a football league. These are similar to the league tables you see in the paper all the time for the CIS, CFL, NFL, and other leagues.
The table will be stored in 6 lists:
a list with the team names
a list with the number of wins for each team
a list with the number of losses for each team
a list with the total number of points scored for each team
a list with the total number of points scored against each team
a list with the total number of points earned in the standings (2 points for each win)
These lists correspond to one another in the sense that the data for team i will be the i-th element of each list. For example, if Layabouts is the third element of the team names list, their number of wins will be the third element of the number of wins list, their number of losses the third element of the number of losses list, and so on across all of the lists.
For the assignment you are to write scripts as described below.
Part 1 – Getting Scores into the Table
First, initialize the lists above, entering your team names in the first list, and 0’s for all the elements of the other lists. Your next task is to write a script to enter scores into the table. This will be done by a script attached to a sprite representing the league statistician. When the sprite is clicked, the user is asked for a new score. This is entered as a string such as “Layabouts 23 Luddites 14”. The winning team and score will always come first, then the losing team and score. You can assume that the names and scores will be separated by exactly one blank character, and that there will be no blank at the end or beginning of the string. When presented with this string, the script must
add 1 to the Layabouts number of wins
add 1 to the Luddites number of losses
add 23 to the Layabouts total number of points scored for
add 23 to the Luddites total number of points scored against
add 14 to the Layabouts total number of points scored against
add 14 to the Luddites total number of points scored for
add 2 to the Layabouts total number of points earned
You may want to create helper scripts to do things like breaking out the next word from a string, and/or to find the position of a team in the table and/or to help you initialize the table. [60 marks]
Part 2 – Getting Information Out of the Table
Each team will have its own sprite (hopefully one appropriate to the team name) that, when clicked, will find out information about that team from the table. The sprite will provide two kinds of information:
the team’s ranking, 1st, 2nd, 3rd, etc., in terms of number of points in the standings [15 marks]
how many points behind the leader the team is (this will be 0 if the team is in first place) [15 marks]
The sprite should say this information in a speech bubble.
You should test your scripts in both Part 1 and Part 2 on a league with at least 4 teams. Use your imagination in the design of the team names, and the look and feel of the sprites and the stage. Add comments to your scripts to label the important steps and to explain what each script is meant to do. [10 marks]
If anyone can do this and send me a pic or upload the project i would be greatful!!
Offline
That sounds like a pretty advanced assignment. You're going to need to write a script that breaks a string by spaces (to find out who won, and by how much). You'll also need to loop through the scores and order them, while keeping track of which team has what score, I'd probably use a duplicate list to help. Finding information about the teams is pretty straight forward (simply "say" the items of the list that correlate with the team). I'm reluctant to be more helpful (offering actual scripts or making the assignment) as this is a school assignment, sorry.
Offline
Ya, im really having lots of trouble and i dont understand most of what u said but thanks for your help. The part i cant get is the script to break the string into spaces i have no clue.
Offline
What you could do is have one script that breaks down the string into list items based off the spaces in the string. This means that item 1 of a list is the first team, item 2 is their score, item 3 is the second team, and item 4 is their score. This would allow you to later compare scores and very easily add the scores to right items. I'm not gonna go into any more depth because, as MoreGamesNow said, this is a school assessment.
Offline
You mean you are having trouble with separating the words? Try using the letter of block and loops...as well as a couple of other things I won't say; think about it though - combined with the post by atomic above it shouldn't be too hard.
This is only a suggestion, there may be an easier way, I guess.
If you still have trouble just post here again or comment on one of my projects and I'll try to help you.
Good luck.
Offline
Okay, my resolve is broken. You'll find how to split strings by space here
Offline
Hm... Sounds quite complicated. If you don't get what anyone else has said, try the scratch wiki, but if you're still stuck then just explain to your teacher that you're really stuck, and then he/she'll probably help you
Offline
What would be a list and what would i set as variables?
Offline
Tylerbreeze wrote:
What would be a list and what would i set as variables?
I answered this in that other forum, but if you check here first:
- i is just a counter, ignore it
- j is just a counter, ignore it
- variable contains the string the user inputed
- list is the list that will contain all the words in variable.
Offline
i tried this code and it doesnt break it it just puts everything in a list in the first slot
Offline
Tylerbreeze wrote:
i tried this code and it doesnt break it it just puts everything in a list in the first slot
I've just retried the code and it works for me.
You may have mistaken what I wanted in the if-else statement. I wanted:
letter (i) of (variable) = [ ]
There has to be a space in there.
If you're interested, I've re-written the script and eliminated the j variable:
set [i] to (0) delete (all) of [list] add () to [list] repeat (length of variable) { change [i] by (1) if(letter (i) of (variable) == [ ] ) { add () to [list] } else { replace item (last) of [list] with (join ((item (last) of [list]) with (letter (i) of (variable))) } }
Offline
WOW, thanks u saved my butt. Your really good i appreciate all your help i got it to work. now i just have to figure out how to make it do everything i want.
Offline