Browse Source

5.3: a player with 40 points.

Frederic G. MARAND 5 years ago
parent
commit
b62a9cc876
2 changed files with 65 additions and 19 deletions
  1. 15 9
      .idea/workspace.xml
  2. 50 10
      course/index.ts

+ 15 - 9
.idea/workspace.xml

@@ -48,13 +48,13 @@
       <usages-collector id="statistics.file.extensions.edit">
         <counts>
           <entry key="json" value="102" />
-          <entry key="ts" value="6022" />
+          <entry key="ts" value="6735" />
         </counts>
       </usages-collector>
       <usages-collector id="statistics.file.types.edit">
         <counts>
           <entry key="JSON" value="35" />
-          <entry key="TypeScript" value="6022" />
+          <entry key="TypeScript" value="6735" />
           <entry key="tsconfig" value="67" />
         </counts>
       </usages-collector>
@@ -75,8 +75,8 @@
       <file pinned="false" current-in-tab="true">
         <entry file="file://$PROJECT_DIR$/course/index.ts">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="270">
-              <caret line="18" column="31" selection-start-line="18" selection-start-column="31" selection-end-line="18" selection-end-column="31" />
+            <state relative-caret-position="690">
+              <caret line="58" column="2" lean-forward="true" selection-start-line="58" selection-start-column="2" selection-end-line="58" selection-end-column="2" />
             </state>
           </provider>
         </entry>
@@ -194,6 +194,12 @@
               <item name="Pluralsight-GetTheMostFromTypescript" type="462c0819:PsiDirectoryNode" />
               <item name="05" type="462c0819:PsiDirectoryNode" />
             </path>
+            <path>
+              <item name="Pluralsight-GetTheMostFromTypescript" type="b2602c69:ProjectViewProjectNode" />
+              <item name="Pluralsight-GetTheMostFromTypescript" type="462c0819:PsiDirectoryNode" />
+              <item name="05" type="462c0819:PsiDirectoryNode" />
+              <item name="demos" type="462c0819:PsiDirectoryNode" />
+            </path>
             <path>
               <item name="Pluralsight-GetTheMostFromTypescript" type="b2602c69:ProjectViewProjectNode" />
               <item name="Pluralsight-GetTheMostFromTypescript" type="462c0819:PsiDirectoryNode" />
@@ -279,7 +285,7 @@
     <servers />
   </component>
   <component name="TimeTrackingManager">
-    <option name="totallyTimeSpent" value="24124000" />
+    <option name="totallyTimeSpent" value="25155000" />
   </component>
   <component name="ToolWindowManager">
     <frame x="0" y="23" width="1440" height="877" extended-state="6" />
@@ -290,7 +296,7 @@
       <window_info id="npm" order="2" side_tool="true" weight="0.3297568" />
       <window_info anchor="bottom" id="Event Log" order="0" sideWeight="0.5007153" side_tool="true" weight="0.3299363" />
       <window_info anchor="bottom" id="Version Control" order="1" />
-      <window_info active="true" anchor="bottom" id="Terminal" order="2" sideWeight="0.49928468" visible="true" weight="0.3299363" />
+      <window_info anchor="bottom" id="Terminal" order="2" sideWeight="0.49928468" weight="0.3299363" />
       <window_info anchor="bottom" id="Metrics" order="3" />
       <window_info anchor="bottom" id="Message" order="4" />
       <window_info anchor="bottom" id="Find" order="5" weight="0.3299363" />
@@ -307,7 +313,7 @@
       <window_info anchor="right" id="Commander" order="2" weight="0.4" />
       <window_info anchor="right" id="Ant Build" order="3" weight="0.25" />
       <window_info anchor="right" content_ui="combo" id="Hierarchy" order="4" sideWeight="0.49582636" weight="0.24964234" />
-      <window_info anchor="right" content_ui="combo" id="Project" order="5" sideWeight="0.49429658" visible="true" weight="0.25894135" />
+      <window_info active="true" anchor="right" content_ui="combo" id="Project" order="5" sideWeight="0.49429658" visible="true" weight="0.25894135" />
       <window_info anchor="right" id="Remote Host" order="6" show_stripe_button="false" />
       <window_info anchor="right" x="0" y="0" width="310" height="677" id="Documentation" order="7" sideWeight="0.50570345" side_tool="true" weight="0.25894135" />
     </layout>
@@ -574,8 +580,8 @@
     </entry>
     <entry file="file://$PROJECT_DIR$/course/index.ts">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="270">
-          <caret line="18" column="31" selection-start-line="18" selection-start-column="31" selection-end-line="18" selection-end-column="31" />
+        <state relative-caret-position="690">
+          <caret line="58" column="2" lean-forward="true" selection-start-line="58" selection-start-column="2" selection-end-line="58" selection-end-column="2" />
         </state>
       </provider>
     </entry>

+ 50 - 10
course/index.ts

@@ -1,19 +1,59 @@
-type Point = "love" | "15" | "30" | "40";
-
+type PlayerOne = {
+    kind: "playerOne";
+    name: string;
+};
+type PlayerTwo = {
+    kind: "playerTwo";
+    name: string;
+};
+type Player = PlayerOne | PlayerTwo;
+type Point = "love" | "15" | "30";
 type Deuce = {
     kind: "deuce";
 };
-
 type PointsData = {
     kind: "points";
-    pointsPlayerOne: Point;
-    pointsPlayerTwo: Point;
+    playerOnePoint: Point;
+    playerTwoPoint: Point;
 };
-
-type Score = Deuce | PointsData;
+type FortyData = {
+    kind: "forty";
+    player: Player;
+    otherPlayerPoint: Point;
+};
+type Advantage = {
+    kind: "advantage",
+    player: Player
+};
+type Game = {
+    kind: "game",
+    player: Player
+    // otherPlayerPoint: ? Not representable here.
+};
+type Score = Deuce | PointsData | FortyData | Advantage | Game;
 
 const s1: Score = {
     kind: "points",
-    pointsPlayerOne: "40",
-    pointsPlayerTwo: "40",
-}; // invalid, should be deuce.
+    playerOnePoint: "30",
+    playerTwoPoint: "love",
+};
+
+const s2: Score = {
+    kind: "deuce",
+};
+
+const s3: Score = {
+    kind: "forty",
+    player: { kind: "playerOne", name: "Serena" },
+    otherPlayerPoint: "love",
+};
+
+const s4: Score = {
+    kind: "advantage",
+    player: { kind: "playerTwo", name: "Venus" },
+};
+
+const s5: Score = {
+    kind: "game",
+    player: { kind: "playerOne", name: "Martina" },
+};