Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
202 commits
Select commit Hold shift + click to select a range
5ffe9d5
module 1 update 1
tar3kmp3 Jun 8, 2022
ec64886
module 1
tar3kmp3 Jun 10, 2022
0f93906
working on module2
tar3kmp3 Jun 10, 2022
cb7592a
recommitting module 1
tar3kmp3 Jun 10, 2022
8743ec9
module2 commit 2
tar3kmp3 Jun 10, 2022
fed720f
finished module 2
tar3kmp3 Jun 11, 2022
7b70324
module 3 done
tar3kmp3 Jun 11, 2022
d724817
m3 updates, started m4
tar3kmp3 Jun 12, 2022
15fed16
module 4 done
tar3kmp3 Jun 13, 2022
c2b1d5c
module 5 done
tar3kmp3 Jun 16, 2022
b1aca68
module 6 done
tar3kmp3 Jun 19, 2022
1719861
module 7 done
tar3kmp3 Jun 20, 2022
af1bf9c
module 8 and 9
tar3kmp3 Jun 22, 2022
1f2123e
reorganized
tar3kmp3 Jun 29, 2022
9e1f385
get_master_url()
tar3kmp3 Jul 4, 2022
0f54e43
updating book settings
digshake Aug 25, 2022
20c4d04
started incorporating 131 materials
Aug 25, 2022
19fbe3f
major restructure
digshake Aug 26, 2022
30d12d4
major reorg
digshake Aug 27, 2022
923bedd
fixing git links
digshake Aug 27, 2022
fd11934
updating module 0
digshake Aug 27, 2022
03f3e69
module 0 fixes
digshake Aug 27, 2022
14a6fa4
update css
digshake Aug 27, 2022
89cedbd
update css
digshake Aug 27, 2022
ac3dd1b
update css
digshake Aug 27, 2022
a8d124d
update css
digshake Aug 27, 2022
674ea50
update css
digshake Aug 27, 2022
a9aa90b
update settings
digshake Aug 27, 2022
1bd76fc
updated toc
digshake Aug 27, 2022
33d0b09
reshuffle modules 1 and 2
digshake Aug 27, 2022
0b092ab
restructure first batch
digshake Aug 27, 2022
21daa3a
restructure first batch
digshake Aug 27, 2022
c0d357d
whoops
digshake Aug 27, 2022
c4b71df
small fixes
digshake Aug 27, 2022
dcf5d01
updating module 1
digshake Aug 27, 2022
3fee9b5
updating module 1
digshake Aug 27, 2022
37c1153
finish review of first 3 modules
digshake Aug 28, 2022
70f8cd4
finish review of first 3 modules
digshake Aug 28, 2022
9ebb15b
updating software instructions
digshake Aug 29, 2022
4a89831
software install updates
digshake Aug 31, 2022
057b17d
software install updates
digshake Aug 31, 2022
885f286
updating studio 0
digshake Aug 31, 2022
e11f6f4
udpating studio 0 link
digshake Aug 31, 2022
eee27dc
first batch of extensions
digshake Sep 5, 2022
ad6e7b2
removing extensions from main menu
digshake Sep 5, 2022
e765323
extensions updates
digshake Sep 5, 2022
08f84e2
extensions updates
digshake Sep 5, 2022
4e66cc5
extensions updates
digshake Sep 5, 2022
7914887
extensions updates
digshake Sep 5, 2022
9df7f78
extensions updates
digshake Sep 5, 2022
50120f6
extensions updates
digshake Sep 5, 2022
78abe0c
extensions updates
digshake Sep 5, 2022
3b7062c
extensions updates
digshake Sep 5, 2022
7011080
extensions updates
digshake Sep 5, 2022
2605680
extensions updates
digshake Sep 5, 2022
d069ccc
extensions updates
digshake Sep 5, 2022
b4831ab
extensions updates
digshake Sep 5, 2022
7ff9c0f
extensions updates
digshake Sep 5, 2022
922251b
extensions updates
digshake Sep 5, 2022
d4e4eb7
extensions updates
digshake Sep 5, 2022
7042889
updating studio 1
digshake Sep 7, 2022
1169444
updates to studio 1
digshake Sep 8, 2022
149cdbc
studio and assignment 1 fixes
digshake Sep 12, 2022
2b609bd
publishing extensions
digshake Sep 13, 2022
06a38e5
fixing extensions
digshake Sep 20, 2022
2796d90
updating an extension
digshake Sep 21, 2022
1d62b4c
updating extension points
digshake Sep 26, 2022
1999885
extension points
digshake Oct 3, 2022
1524083
extension points
digshake Oct 3, 2022
089436a
module 4 wip
digshake Oct 4, 2022
15df272
updating second third
digshake Oct 4, 2022
967934b
here we go, second third ready for proofing
digshake Oct 5, 2022
8214e65
here we go, second third ready for proofing
digshake Oct 5, 2022
6fe00a8
toc fix
digshake Oct 5, 2022
3e12693
toc fix
digshake Oct 5, 2022
dfc4225
toc fix
digshake Oct 5, 2022
761b845
extension batch 2 wip
digshake Oct 14, 2022
771258e
work in progress
digshake Oct 17, 2022
343c71b
extension batch 2 draft
digshake Oct 17, 2022
4a25269
fixing some stuff
digshake Oct 18, 2022
205f1cf
fixing some stuff
digshake Oct 18, 2022
fe1008f
fixing some stuff
digshake Oct 18, 2022
ce4efc0
fixing some stuff
digshake Oct 18, 2022
12a6352
fixing some stuff
digshake Oct 18, 2022
e5b63de
fixing some stuff
digshake Oct 18, 2022
32adf85
fixing some stuff
digshake Oct 18, 2022
d30d212
fixing some stuff
digshake Oct 18, 2022
ce5e307
fixing some stuff
digshake Oct 18, 2022
8472849
module 7
digshake Oct 26, 2022
18d82a2
title change
digshake Oct 27, 2022
cd36177
EB1 and Studio 6 edits
cgnov Oct 27, 2022
9b30449
Merge branch 'master' of https://github.com/digshake/CSJavaWUSTL
cgnov Oct 27, 2022
9a27229
Smol Studio 5 edits (typos, capitalization, titles)
cgnov Oct 27, 2022
6cecb81
Clarify A7 confusions
cgnov Nov 7, 2022
c743d7a
module 8
digshake Nov 14, 2022
2fb89bb
module 8
digshake Nov 14, 2022
2a100fa
studio 8 updates and fixes
digshake Nov 16, 2022
9fed312
formatting
digshake Nov 16, 2022
9733781
fixing github link
digshake Nov 16, 2022
6c744b6
module 9 stuff
digshake Nov 22, 2022
80d54d1
studio 9 updates
digshake Nov 28, 2022
dd28918
updating for spring 23
digshake Jan 10, 2023
67757c5
setup and assignment 1 edits
digshake Jan 11, 2023
af62d6a
setup and assignment 1 edits
digshake Jan 11, 2023
b964109
setup and assignment 1 edits
digshake Jan 11, 2023
c8392d9
Studio 0 rewording
cgnov Jan 12, 2023
8027c0a
Merge
cgnov Jan 12, 2023
758e40c
Fix Studio 0 Github links
cgnov Jan 12, 2023
7286781
setup instruction updates
digshake Jan 12, 2023
b5790d5
Merge branch 'master' of https://github.com/digshake/CSJavaWUSTL
digshake Jan 12, 2023
b0d4dea
setup instruction updates
digshake Jan 12, 2023
f6d9a81
setup instruction updates
digshake Jan 12, 2023
3d1fce6
Add empty lines to fix "definition list" bolding
cgnov Jan 12, 2023
3645565
Merge branch 'master' of https://github.com/digshake/CSJavaWUSTL
cgnov Jan 12, 2023
0008071
Studio 0 formatting - smaller list indents
cgnov Jan 13, 2023
552ef16
slight update to software installation instructions
digshake Jan 17, 2023
4abcf4d
Suggest new group in Studio 1
cgnov Jan 19, 2023
7401c24
Merge branch 'master' of https://github.com/digshake/CSJavaWUSTL
cgnov Jan 19, 2023
9496f1f
A0 re-flow
cgnov Jan 23, 2023
5a3c465
Add Studio 2 conceptual checkpoints
cgnov Jan 24, 2023
2c1785e
Remove extra 0s in A1 output
cgnov Jan 25, 2023
5908dfb
A1 styling and content fixes
cgnov Jan 25, 2023
b438150
S1 hotfix
cgnov Jan 26, 2023
5c8e6d2
Studio Team name number fixes
cgnov Jan 26, 2023
aa41a2b
Fix A1 rounding
cgnov Jan 27, 2023
2bcbfc9
slight modification to studio 1
digshake Jan 27, 2023
8ebbfd5
S3 improvements
cgnov Feb 2, 2023
774adff
Merge branch 'master' of https://github.com/digshake/CSJavaWUSTL
cgnov Feb 2, 2023
968a726
Fix S3 number
cgnov Feb 2, 2023
7f8cea4
Add A3 freq table tips
cgnov Feb 4, 2023
dc01281
E1.1 syntax fix
cgnov Feb 4, 2023
f0c5f6e
E2.1: Give loop variable name tip
cgnov Feb 4, 2023
aed082a
E3.1 format fixes
cgnov Feb 4, 2023
138c66e
Fix E3.5 formatting
cgnov Feb 5, 2023
3e35e9d
E3.5 formatting fix: indent nested list
cgnov Feb 5, 2023
56a2c7c
E3.7 Formatting fixes
cgnov Feb 5, 2023
fe8ff5d
E1.1 Add JUnit primer and allow if when no fine
cgnov Feb 5, 2023
cf4f2cb
E2.1: Elaborate on testing
cgnov Feb 5, 2023
6758d1a
E3.7: Remove outdated hint
cgnov Feb 7, 2023
5c223ae
S4 setup simplification + format fixes
cgnov Feb 16, 2023
3289e50
E3.5 Show correct points for Data Sorting in title
cgnov Feb 17, 2023
71097c6
fixing image path
digshake Mar 7, 2023
f611419
updating for fall 23
digshake Aug 24, 2023
201348f
updating for fall 23
digshake Aug 24, 2023
f0eafba
assignment 1 tweak
digshake Sep 6, 2023
c70c5e5
fixing studio 1 link
digshake Sep 6, 2023
eec4e60
fixing incorrect weights
digshake Sep 8, 2023
c9014f8
Merge branch 'master' of https://github.com/digshake/CSJavaWUSTL
digshake Sep 8, 2023
4eb24ae
studio 3
digshake Sep 20, 2023
d0be2e7
updating for exam prep 1
digshake Sep 22, 2023
896c242
updating for exam prep 1
digshake Sep 22, 2023
fbb8fbe
fixing github link
digshake Oct 2, 2023
52c7bab
Merge branch 'master' of https://github.com/digshake/CSJavaWUSTL
digshake Oct 2, 2023
1bf4f28
reordering problems, fixing a typo, adding alert to only write code i…
victoriaprisco Oct 23, 2023
d3c4097
Merge pull request #1 from digshake/Studio6Changes
digshake Oct 25, 2023
1e1e8e0
updating modules 8 and 9
digshake Oct 27, 2023
8a6fd8a
Merge branch 'master' of https://github.com/digshake/CSJavaWUSTL
digshake Oct 27, 2023
a48477f
updating toc
digshake Oct 27, 2023
4357d7c
updating toc
digshake Oct 27, 2023
11e3dc5
updating toc
digshake Oct 27, 2023
9ea3e54
updating exam prep 2
digshake Oct 31, 2023
30ab414
reorg
digshake Nov 9, 2023
62e8325
assignment 8
digshake Nov 11, 2023
777c931
studio 8
digshake Nov 11, 2023
2529fa9
fixing toc
digshake Nov 11, 2023
2afa7ca
fixing studio 8
digshake Nov 11, 2023
38aa3d1
fixing studio 8
digshake Nov 11, 2023
7d3d0b6
studio 8 and assignment 8 fixes
digshake Nov 14, 2023
1aa5a34
removing sets
digshake Nov 20, 2023
534958c
updating equality
digshake Nov 20, 2023
04e2b5a
updating equality
digshake Nov 20, 2023
b9424e6
updating module 9 assignment and studio
digshake Nov 26, 2023
9adfd10
updating toc
digshake Nov 26, 2023
43a13b3
fixing typos and such
digshake Nov 26, 2023
e35a0e2
fixing typo
digshake Nov 28, 2023
6899f8f
updating studio 8
digshake Nov 29, 2023
118dbd2
adding exam 3 prep
digshake Dec 1, 2023
316be33
updating GHC links
digshake Jan 11, 2024
11bfb51
updating module 3 exercises
digshake Feb 6, 2024
507f8c3
update typo in module 4 studio instructions
victoriaprisco Mar 20, 2024
16b5c17
updating studio 8 instructions
digshake Apr 3, 2024
0c30529
updating assignment 8
digshake Apr 10, 2024
dc3c0c3
assignment 9 tweak
digshake Apr 20, 2024
1c10b58
adding github links and questions
digshake Aug 21, 2024
9cc29f6
moving assignment 4 images
digshake Aug 21, 2024
e30165c
updating file names for modules 1 thru 3
digshake Aug 23, 2024
59679d4
updating brackets for modules 1 thru 3
digshake Aug 23, 2024
a64bb9d
removing page
digshake Aug 23, 2024
3844dca
fixing assignment 0 link
digshake Aug 26, 2024
9c29c74
fixing repo link
digshake Sep 16, 2024
c789339
fixing studio link
digshake Sep 16, 2024
cf3abcc
fixing frequency table
digshake Sep 16, 2024
cdb43b3
file names and formatting
digshake Sep 23, 2024
c6ef818
new assignment 4!
digshake Sep 24, 2024
b8918c8
new assignment 4!
digshake Sep 24, 2024
0734d15
new assignment 4!
digshake Sep 24, 2024
871d366
new assignment 4!
digshake Sep 24, 2024
5bb8eed
new assignment 4!
digshake Sep 24, 2024
a4f693e
new assignment 4!
digshake Sep 24, 2024
dc0496e
assignment 5 tweaks
digshake Sep 25, 2024
c890f83
assignment tweaks
digshake Sep 25, 2024
58f6c5c
update reference to old assignment 4
victoriaprisco Oct 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
84 changes: 84 additions & 0 deletions _sources/Extensions/1.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
======================================================
Extension 1.1: Speed Limit Fine Calculator (3 points)
======================================================

Authors:

* `Ron K. Cytron <http://www.cs.wustl.edu/~cytron/>`_
* Michael Waldman
* Alan Waldman
* Cameron Wong

You will calculate the fine drivers have to pay when going over the speed limit in the state of Massachusetts according to the `Massachusetts DMV <http://www.dmv.org/ma-massachusetts/traffic-tickets.php>`_.

By completing this work, you demonstrate that you can:

* Create a Java class on your own
* Arrange for the class to take inputs of interest
* Compute output values of interest
* Produce meaningful output based on your computations

The objective of this extension is to allow you to practice **assignment statements** and **data types** as well as for you to create a practical tool, though of course we hope you never need to compute a speeding fine for yourself.

Consider the following story:

* Pat is driving a Mini Cooper at 85 MPH on a road that has the speed limit of 60 MPH.
* Pat is therefore going 25 MPH over the speed limit.
* If Pat is caught speeding, what would be Pat's fine?

We'll model the fine after Massachusetts law:

* A fine is assessed only if the driver's speed is over the speed limit.
* The fine is $10 for every mile over the speed limit, but there is a $100 minimum fine.
* Example: If someone is going 75 MPH on a road with a speed limit of 60 MPH, the fine would be 15*$10 = $150.
* Example: If someone is going 65 MPH on a road with a speed limit of 60 MPH, the fine would be $100.

Procedure
==================


1. First, create a **SpeedLimit** Java class in the ``speeding`` package of the ``extensions`` source folder.
2. Consider and decide upon the **data type** to represent information of interest to this problem.
3. You must ask the user for input values for the driver's speed and the speed limit. For the automated test to work properly, please ask in that order.
4. Arrange for your program to produce output such that if the driver is going at or under the speed limit, the fine is $0 and the only thing you print is "Have a nice day.". (You may use an if statement for this and wrap the rest in an else statement, but you may not use any other if or else if statements.)

5. If the driver is speeding, your program should print how many miles you were going over the speed limit and how much money the fine will be.

Reminder:

* If the driver is going less than 10 miles over the speed limit, the fine is $100.
* If the driver is going over 10 miles over the speed limit, the fine is 10 times the number of miles over the speed limit.

You must compute the fine **without** using `if`-statements. To evaluate an expression conditionally, use the `ternary <http://alvinalexander.com/java/edu/pj/pj010018>`_ operator, an example of which follows:

::

int x = (y > 7) ? 12 : 5;


If ``y``'s value is greater than ``7``, the variable ``x`` is set to ``12``; otherwise ``x`` is set to ``5``.

Sample output based on the example story above:

::

You reported a speed of 85 MPH for a speed limit of 60 MPH.
You went 25 MPH over the speed limit.
Your fine is $250.

Make sure to match the format exactly in order to pass the tests.

Running JUnit tests
===================

JUnit tests allow you to automatically check your work. To run the tests for this extension, right-click on ``SpeedLimitTestSuite.java`` > Run As... > JUnit Test. You may also simply open the Test Suite file and click the green Run button.

Important: when you're running JUnit tests, make sure to comment out any Scanner input-related print statements (such as asking for the driver's speed). The tests don't expect those lines at the beginning.

If your code passes all the tests, you'll see a green bar.

If your code does not pass all the tests, you'll see a red bar. On the bottom-left corner of the screen, you'll see a section titled the "Failure Trace". This section will be extremely useful throughout this class for figuring out how to fix your code!

Usually, test errors will say something along the lines of "expected abc, actual xyz", which means that the correct output would have been "abc", but your program is currently outputting "xyz" for those inputs.

Use these differences to guide your understanding of what parts of your program you need to fix.
91 changes: 91 additions & 0 deletions _sources/Extensions/2.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
========================================================
Extension 2.1: Image Processor With Iteration
========================================================

**Authors**

* `Ron K. Cytron <http://www.cs.wustl.edu/~cytron/>`_
* Ken Goldman
* Logan Sorentino
* `Dennis Cosgrove <http://www.cs.wustl.edu/~cosgroved/>`_


Manipulating an Image Raster
============================

In the ``nonexam.imagetransform`` package, modify the provided ``ImageTransforms`` Java program to implement the methods as described below. Your methods will use iteration (either `while` loops or `for` loops) to operate on the pixels of a picture.

.. youtube:: VJiE78FTohs
:width: 600
:align: center


Testing
============

Some common errors you may see while testing this extension:

* ArrayIndexOutOfBoundsException. This error means you're trying to use an array index that is out of bounds (<0 or >=length). The error will tell you the index you're trying to use and the length of the array, and the second line will tell you which line the error is happening on. (Ex: ImageTransforms.java:70 means the erroneous index is on line 70 of ``ImageTransforms.java``
* NullPointerException. Generally, this error means something is null (hasn't been initialized) that shouldn't be null. For this assignment, that means at least one of the values in ``destination`` is null, which means you didn't finish filling in the values.

For this extension, we recommend using ``ImageTransformsDebugApp`` for a more visual testing experience.

Quick tip: uncheck "display correct results?" on the top right of the debug app to skip to the cases you need to fix.


Instructions
============

Each of the methods described below is found in the ``ImageTransforms`` class.

Quick tip: You will be using a lot of nested for loops in this extension. Reminder that ``i`` is just a variable name and you can name the loop variable anything, like ``row`` or something else descriptive.

1. Complete the method ``Color[][] copy(Color[][] source)`` to create a new 2D array of Colors which is simply copy the values from source 2D array of Colors.

.. image:: 2.1/copy_gradient.png

.. image:: 2.1/copy_you_belong_here.png

.. image:: 2.1/copy_bear.png

2. Complete the method ``Color[][] flipHorizontal(Color[][] source)`` to create a new 2D array of Colors which contains the flipped horizontally values from source 2D array of Colors.


.. image:: 2.1/flip_horizontal_gradient.png

.. image:: 2.1/flip_horizontal_you_belong_here.png

.. image:: 2.1/flip_horizontal_bear.png

3. Complete the method ``Color[][] flipVertical(Color[][] source)`` to create a new 2D array of Colors which contains the flipped vertically values from source 2D array of Colors.

.. image:: 2.1/flip_vertical_gradient.png

.. image:: 2.1/flip_vertical_you_belong_here.png

.. image:: 2.1/flip_vertical_bear.png

4. Complete the method ``Color[][] mirrorLeftOntoRight(Color[][] source)`` to create a new 2D array of Colors which contains mirrored values from source 2D array of Colors.

> The left half of the target image should be same as the source, but the right half of the destination image should be the mirror of the left half of the source.

.. image:: 2.1/mirror_left_onto_right_gradient.png

.. image:: 2.1/mirror_left_onto_right_you_belong_here.png

.. image:: 2.1/mirror_left_onto_right_bear.png

5. Complete the method ``Color[][] rotateRight(Color[][] source)`` to create a new 2D array of Colors which contains rotated right values from source 2D array of Colors.

Note: the dimensions of the returned destination are different from the source.

.. image:: 2.1/rotate_right_gradient.png

.. image:: 2.1/rotate_right_you_belong_here.png

.. image:: 2.1/rotate_right_bear.png





Binary file added _sources/Extensions/2.1/copy_bear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _sources/Extensions/2.1/copy_gradient.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _sources/Extensions/2.1/copy_you_belong_here.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _sources/Extensions/2.1/flip_horizontal_bear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _sources/Extensions/2.1/flip_vertical_bear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _sources/Extensions/2.1/rotate_right_bear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _sources/Extensions/2.1/rotate_right_gradient.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
98 changes: 98 additions & 0 deletions _sources/Extensions/2.3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
=================
Extension 2.3: Rock-Paper-Scissors
=================

**Authors**

* `Ron Cytron <http://www.cs.wustl.edu/~cytron/>`_

The game of `Rock-Paper-Scissors <https://en.wikipedia.org/wiki/Rock-paper-scissors>`_ (hereafter, RPS) is a two-player game that can be used to avoid boredom and to settle disputes.

In this extension you will simulate two players: one plays randomly while
the other rotates faithfully from rock to paper to scissors. Your task is
to simulate this game and to report the fraction of games won by
each of the two players.

Procedure
==================

Find the ``nonexam.rockpaperscissors`` package in the source folder.

It is suggested that you develop code in small steps, so that you can proceed from confidence to confidence, and not have a big pile of untested code to debug at the end.

To help motivate this approach, the TAs will not help you unless you have shown progress based on these steps. Ask for help as soon as you need it, but please follow the steps below so that you can gain confidence.

The steps you might consider are as follows:

1. What inputs does your program need? First, get your program to accept those inputs and print them out so you can see they are set properly.

This means that you should type in the code to prompt the user for the input(s), print out the values of those inputs, and that\'s all for now. Run your program at this point
and make sure it is behaving as you want.
What inputs do you need? There\'s no reason to ask for more than is necessary. At a minimum, you have to know how many rounds of RPS to play before printing the resulting
statistics

2. Next, create a loop that simply iterates the desired number of times.

Again, run your program. You may want to print something out in your loop so you can
verify that the loop works correctly.

3. You next can make the concept of the random player real. This means declaring a variable name of a suitable type to represent this concept, establishing the variable\'s initial value.

What is the concept of the player? There are many details about the
player that appear unnecessary: the player\'s name, address, cell phone number.

On the other hand, if we are going to play RPS, we need to know what move the player has made. This is the important concept.

How do we represent the choice of rock, paper, or scissors?
This is left up to you, so try for something simple. It may help to recall how Paul
Revere was `poetically <http://www.nationalcenter.org/PaulRevere%27sRide.html>`_ told of how the British were coming: one if by land,
two if by sea.

In otherwords, an ``int`` encoded the manner of invasion.

If there were only two choices, why didn\'t Paul use a ``boolean``?
Sadly, `Boole <https://en.wikipedia.org/wiki/George_Boole>`_
was not yet born

4. In your loop, you should modify this variable\'s value to reflect the associated player choosing randomly among rock, paper, and scissors each iteration.

You\'ve seen how to use the random number generator to pick between two outcomes.
Now you must pick between three.

5. Run your program and verify that the player is choosing randomly.

6. OK, now for the other player. This player must cycle among rock, paper, and scissors. Let\'s make this player real by declaring a variable name of a suitable type and establishing its initial value.

In the interest of consistency and simplicity, you should use the same
encoding for this player in terms of what value means rock, what value means
paper, and what value means scissors.

7. In your loop, arrange for this player to choose its next move based on its previous move. If the move used to be rock, it\'s now paper. If the move used to be paper, it\'s now scissors. If the move was scissors, it\'s now rock.

8. Run your program again and make sure the cycling player is behaving properly.

To verify the cycling player\'s behavior, you will probably want to print out
the values representing that player\'s move each iteration.

It won\'t take many iterations to see if this is working or not: 10 should do.

9. Each player has made a move; now let\'s see who won. First, pick a name, type, and initial value for the number of wins a player has. Do the same for the other player.

Why do we need a variable to keep track of each player\'s wins?
Why not keep track of only one player\'s wins and assume the other player won the
other rounds?

10. In the loop, determine who won based on the current value of each player\'s move.

Use the `rules <https://en.wikipedia.org/wiki/Rock-paper-scissors#Game_play>`_
of RPS to adjudicate the winner,
and credit the win count properly.

11. After the loop completes, report the fraction of wins awarded to each of the two players.

12. Test your code by trying it with just one iteration, two iterations, and three iterations. Make sure it\'s working before you set it loose.

13. Run your code several times, each on 1000 iterations.

14. Based on what you see, did one player tend to win more often than the other?

75 changes: 75 additions & 0 deletions _sources/Extensions/2.5.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
=========================
Extension 2.5: Mario
=========================

Authors:

* Nathan Vogt
* Elie Schramm
* Dotun Taiwo

`Mario <https://en.wikipedia.org/wiki/Mario_(franchise)>`_, created in 1981 by Nintendo, is a classic video game starring the fictional Italian character Mario. In the assignment, loops printing hashtags will be used to build the block mountains as seen in the picture.

.. image:: Super-Mario-Bros.-3.jpg

* Find and open the Java class Mario in the ``nonexam.mario`` package.
* Your program must first prompt the user for two integer inputs using ``Scanner``. These must be requested in the following order:

``size``: What is the size of the mountain? In the picture above, the mountain has size 5 because there are 5 levels of squares, and the widest part of the mountain, at its bottom, is also 5 squares. A mountain will always be a square structure containing size×size elements, some of which are hashtags (#) and some of which are blanks.

``pattern``: We will use an integer in the range 1 to 4 to indicate which pattern your program should produce. In the picture above, pattern 1 is shown. The other patterns are explained below

* Your program then prints the mountain of the specified size and pattern.

1. Mario runs from left to right. Create a mountain that he would have to climb, as shown in the example for a size 5 mountain.

::

#
##
###
####
#####


2. Create a mountain that he would descend, as shown below for a size 3 mountain.

::

#
##
###


3. Make a mountain that resembles pattern 1, but flipped upside-down. Below is shown a size 7 mountain for this pattern.

::

#######
######
#####
####
###
##
#


4. Make a mountain that resembles pattern 2, but flipped upside down. Below is shown a size 4 mountain for this pattern.

::

####
###
##
#


Try running your Mario class and test yourself using various sizes (say, 1 to 10) and patterns (always an integer from 1 to 4).

Note that this problem requires careful use of `whitespace <https://en.wikipedia.org/wiki/Whitespace_character>`_ which are the characters like tab, space, and newlines that don't show anything in the foreground color. On a white background whitespace characters don't have a visible impact, but they do move the cursor to a new location. In particular:

* Avoid extra spaces at the beginning of lines

* Avoid using more ``ln`` s than needed. For example, if the size is 5 there should be exactly 5 things that move to a new line (5 ``println`` s or 5 ``\n`` s or a mix of the two.)


Loading