Skip to content

Commit

Permalink
Code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Adb committed Aug 16, 2012
1 parent 84d95da commit c13c5c3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
13 changes: 6 additions & 7 deletions BurkeA_assignment3.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@
var teams = []; // Holds an array of hockeyTeam objects created

// Constructor
var hockeyTeam = function (name, coach) {
var HockeyTeam = function (name, coach) {
// Private
var roster = [];

// Accessors
var getName = function () { return name; };
var getCoach = function () { return coach; };
var getPlayer = function (player,json) { // Takes a player name and JSON data from json.js
var getPlayer = function (player, json) { // Takes a player name and JSON data from json.js
var playerInfo;
for (var i =0, j = roster.length; i < j; i++){ // loop to see if player is on roster if found break and move on
for (var i = 0, j = roster.length; i < j; i++) { // loop to see if player is on roster if found break and move on
//console.log("got here"); // Debug check on loop
//console.log(roster[i]); // Debug check on loop
if (roster[i] === player){
Expand All @@ -28,7 +27,7 @@ var hockeyTeam = function (name, coach) {
playerInfo = "Player not on roster.";
return playerInfo;
};
for (var ii = 0, jj = json.players.length; ii < jj; ii++){ // Loop through json object of players to find info
for (var ii = 0, jj = json.players.length; ii < jj; ii++) { // Loop through json object of players to find info
//console.log("got here also"); // Debug check on loop
var play = json.players[ii];
//console.log(play.name + " " + roster[i]); // Debug check on loop
Expand Down Expand Up @@ -115,10 +114,10 @@ var hockeyTeam = function (name, coach) {

// Create Team
console.log("Time to create some Hockey Teams!");
var team1 = hockeyTeam("Ravens", "Joe Mann");
var team1 = HockeyTeam("Ravens", "Joe Mann");
console.log(team1.getName() + " team created and the coach is " + team1.getCoach() + ".");
teams.push(team1);
var team2 = hockeyTeam("Black Hawks", "Sean Smith");
var team2 = HockeyTeam("Black Hawks", "Sean Smith");
console.log(team2.getName() + " team created and the coach is " + team2.getCoach() + ".");
teams.push(team2);
console.log(" ");
Expand Down
28 changes: 14 additions & 14 deletions json.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,111 +12,111 @@ var playerData = {
"age": 30,
"hand": "Right",
"position": "Center",
"born": ["2-23-82","Lacrosse","WI"],
"born": ["2-23-82", "Lacrosse", "WI"],
"playedCollege": true
},
{
"name": "John Doe",
"age": 24,
"hand": "Left",
"position": "Left Wing",
"born": ["5-13-88","Chicago","IL"],
"born": ["5-13-88", "Chicago", "IL"],
"playedCollege": true
},
{
"name": "Bob Smith",
"age": 21,
"hand": "Right",
"position": "Right Wing",
"born": ["2-5-91","Baltimore","MD"],
"born": ["2-5-91", "Baltimore", "MD"],
"playedCollege": false
},
{
"name": "Mark Jones",
"age": 30,
"hand": "Right",
"position": "Goalie",
"born": ["1-17-82","Ancorage","AK"],
"born": ["1-17-82", "Ancorage", "AK"],
"playedCollege": true
},
{
"name": "Bill Smith",
"age": 20,
"hand": "Right",
"position": "Right Defense",
"born": ["2-23-90","St. Paul","MN"],
"born": ["2-23-90", "St. Paul", "MN"],
"playedCollege": false
},
{
"name": "Robert White",
"age": 28,
"hand": "Left",
"position": "Left Defense",
"born": ["7-20-84","Ann Arbor","MI"],
"born": ["7-20-84", "Ann Arbor", "MI"],
"playedCollege": true
},
{
"name": "Jack Burke",
"age": 34,
"hand": "Right",
"position": "Center",
"born": ["2-20-78","Madison","WI"],
"born": ["2-20-78", "Madison", "WI"],
"playedCollege": true
},
{
"name": "Jim Dole",
"age": 24,
"hand": "Left",
"position": "Left Wing",
"born": ["2-6-88","Boise","ID"],
"born": ["2-6-88", "Boise", "ID"],
"playedCollege": true
},
{
"name": "Ben Dover",
"age": 21,
"hand": "Right",
"position": "Right Wing",
"born": ["9-28-91","Richmond","VA"],
"born": ["9-28-91", "Richmond", "VA"],
"playedCollege": false
},
{
"name": "Mike Jones",
"age": 21,
"hand": "Right",
"position": "Goalie",
"born": ["3-12-91","Miami","FL"],
"born": ["3-12-91", "Miami", "FL"],
"playedCollege": false
},
{
"name": "Matt Black",
"age": 20,
"hand": "Right",
"position": "Right Defense",
"born": ["5-22-90","New York","NY"],
"born": ["5-22-90", "New York", "NY"],
"playedCollege": false
},
{
"name": "Alex Sole",
"age": 28,
"hand": "Left",
"position": "Left Defense",
"born": ["10-2-84","Buffalo","NY"],
"born": ["10-2-84", "Buffalo", "NY"],
"playedCollege": true
},
{
"name": "Joe Best",
"age": 25,
"hand": "Right",
"position": "Right Wing",
"born": ["1-3-87","Vancouver","CAN"],
"born": ["1-3-87", "Vancouver", "CAN"],
"playedCollege": true
},
{
"name": "Mark Good",
"age": 28,
"hand": "Right",
"position": "Right Defense",
"born": ["9-2-84","Ontario","CAN"],
"born": ["9-2-84", "Ontario", "CAN"],
"playedCollege": true
}

Expand Down

0 comments on commit c13c5c3

Please sign in to comment.