Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions 05week/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
<script src='spaceTravelToMars.js'></script>
</html>
32 changes: 31 additions & 1 deletion 05week/spaceTravelToMars.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,44 @@
'use strict';

// this Job-Type array provided for future development, but not used during
// the current testing.
let jobTypes = {
pilot: 'MAV',
mechanic: 'Repair Ship',
commander: 'Main Ship',
programmer: 'Any Ship!'
};

// This class is a CrewMember, who has a Name, performs a Job aboard a Ship,
// has a Special Skill, and may be assigned to a Ship via the enterShip method.
class CrewMember {
constructor (name, job, specialSkill, ship) {
this.name = name;
this.job = job;
this.specialSkill = specialSkill;
this.ship = null;
}
// This method 1) adds the crewMember to the Crew of the assigned Ship, and
// 2) adds the Name of the assigned Ship to the crewMember object.
enterShip (assignedShip) {
assignedShip.crew.push(this);
this.assignedShip = assignedShip;
this.ship = assignedShip;
}
}

// This class creates a Ship object, which has a Name, a Type, an Ability,
// and a Crew array. The ability is a string which describes its mission.
// In order to perform its ability, the ship must have a crew of at least one.
class Ship {
constructor (name, type, ability) {
this.name = name;
this.type = type;
this.ability = ability;
this.crew = [];
}
// If the ship is currently manned by at least one crewMember, this method
// will return its mission. Otherwise it will return a text string indicating
// that the ship is currently unable to perform its mission.
missionStatement () {
if (this.crew.length === 0) {
return `Can't perform a mission yet.`;
Expand All @@ -35,6 +47,24 @@ class Ship {
}
}


/***** MY TESTS USING HTML PAGE
var crewMember1 = new CrewMember('Rick Martinez', 'pilot', 'chemistry');
console.log("crewMember1.name, 'Rick Martinez' ||| crewMember1.job, 'pilot' ||| crewMember1.specialSkill, 'chemistry' ||| crewMember1.ship, null");
let mav = new Ship('Mars Ascent Vehicle', 'MAV', 'Ascend into low orbit');
crewMember1.enterShip(mav);
console.log("crewMember1.ship, mav ||| mav.crew.length, 1 ||| mav.crew[0], crewMember1");
console.log("mav.name, 'Mars Ascent Vehicle' ||| mav.type, 'MAV' ||| mav.ability, 'Ascend into low orbit' ||| mav.crew.length, 0");
let hermes = new Ship('Hermes', 'Main Ship', 'Interplanetary Space Travel');
let crewMember2 = new CrewMember('Commander Lewis', 'commander', 'geology');
console.log("mav.missionStatement(), Can't perform a mission yet. ||| hermes.missionStatement(), Can't perform a mission yet.");
console.log("mav.missionStatement(), Ascend into low orbit");
crewMember2.enterShip(hermes);
console.log("hermes.missionStatement(), Interplanetary Space Travel");
*********/



//tests
let assert = require('assert');

Expand Down
21 changes: 0 additions & 21 deletions 08week/my-app/src/App.js

This file was deleted.

7 changes: 0 additions & 7 deletions 08week/my-app/src/logo.svg

This file was deleted.

54 changes: 54 additions & 0 deletions 08week/simpleStarWars/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
.app {
text-align: center;
background-color: black;
width: 500px;
}

#title {
background-color: black;
height: 20px;
padding: 30px;
color: blue;
}

.name {
height: 35px;
width: 150px;
color: white;
background-color: blue;
}

.spacer {
height: 35px;
width: 60px;
color: black;
background-color: black;
}

.gender {
height: 35px;
width: 50px;
color: white;
background-color: blue;
}

.hair {
height: 35px;
width: 50px;
color: white;
background-color: blue;
}

.eyes {
height: 35px;
width: 50px;
color: white;
background-color: blue;
}

.year {
height: 35px;
width: 50px;
color: white;
background-color: blue;
}
56 changes: 56 additions & 0 deletions 08week/simpleStarWars/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
'use strict';

class StarWars extends React.Component {
constructor (props) {
super(props);
this.resetState = {
characters: [],
}
this.state = {...this.resetState};
}

componentDidMount () {
fetch('https://swapi.co/api/people/')
.then((response) => response.json())
.then((responseJson) => {
return this.setState({characters: responseJson.results});
})
.catch((error) => {
console.error(error);
});
}

renderCharacterData () {
if (this.state.characters) {
return this.state.characters.map((character, index) => {
return (
<tr key={`Row-${index}`}>
<td key={`Name-${index}`} data-characterName={character.name} className='name'>{character.name}</td>
<td key={`Spacer-${index}`} data-characterName={character.name} className='spacer'>.</td>
<td key={`Gender-${index}`} data-characterName={character.name} className='gender'>{character.gender}</td>
<td key={`Eyes-${index}`} data-characterName={character.name} className='eyes'>{character.hair_color}</td>
<td key={`Hair-${index}`} data-characterName={character.name} className='hair'>{character.eye_color}</td>
<td key={`year-${index}`} data-characterName={character.name} className='year'>{character.birth_year}</td>
</tr>
);
});
}
}

render () {
return (
<div className='app'>
<h2 id='title'>Star Wars Trivia Matchup</h2>
<table>
<tbody>
{this.renderCharacterData()}
</tbody>
</table>

</div>
);
}
}


ReactDOM.render(<StarWars />, document.getElementById('game'));
15 changes: 15 additions & 0 deletions 08week/simpleStarWars/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Star Wars Trivia Game</title>
<link rel="stylesheet" href="app.css" />
</head>
<body>
<div id="game"></div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.23.1/babel.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react/15.5.0/react.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react/15.5.0/react-dom.js"></script>
<script type="text/babel" src="app.js"></script>
</body>
</html>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
50 changes: 50 additions & 0 deletions 08week/starWars-app/src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React, { Component } from 'react';
import './App.css';
import CharacterCard from './CharacterCard.js';

class App extends Component {
constructor(props){
super(props);
this.state = {
characters: [],
}
}

componentDidMount(){
fetch('https://swapi.co/api/people/')
.then((response) => response.json())
.then((responseJson) => {
return this.setState({characters: responseJson.results})
})
.catch((error) => {
console.error(error);
});
}

renderCharacters() {
console.log('in renderCharacters');

console.log('characters array', this.state.characters);
}

render() {
return (
<div>
<div className="App">
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h2>Star Wars</h2>
</div>
</div>

<div className="App">
<img src={logo} className="App-logo" alt="logo" />
{this.renderCharacters()}
</div>
</div>
);
}
}


export default App;
File renamed without changes.
17 changes: 17 additions & 0 deletions 08week/starWars-app/src/CharacterCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';

class CharacterCard extends Component {
render() {
console.log(this.props);
return (
<div className="card">
<h2>{this.props.name}</h2>
<p>{this.props.birth_year}</p>
</div>
);
}
}

export default CharacterCard;
File renamed without changes.
File renamed without changes.
Loading