Difference between revisions of "CSC111 Homework 11 2014"

From dftwiki3
Jump to: navigation, search
(Optional and Extra-Credits: Problem 2 (20 points))
(Problem 1 (100 points))
Line 20: Line 20:
 
You have been hired for the summer by a company that makes wrapping paper.  The company has a Web form where customers can pick different colors, a general theme, and a message to print in the middle of the page.  Then a Python program generates an image that is printed by a large format printer.
 
You have been hired for the summer by a company that makes wrapping paper.  The company has a Web form where customers can pick different colors, a general theme, and a message to print in the middle of the page.  Then a Python program generates an image that is printed by a large format printer.
  
The image above shows one particular output, for somebody who has selected ''Cars'' as the theme, ''Yellow'' as the background, and "Happy Easter" as the message.
+
The image above shows one particular output, for somebody who has selected ''Cars'' as the theme, ''Blue'' as the background, and "Happy Easter" as the message.
 
<br />
 
<br />
 
==Your assignment==
 
==Your assignment==
 
<br />
 
<br />
  
You must write a program that generates a sample output, with a predefined color, a predefined scheme, and a predefined message.  Your program will '''NOT''' ask the user for any information.
+
You must demonstrate that you can have the programming job by writing a program that generates a sample output, with a predefined color, a predefined scheme, and a predefined message.  Your program will '''NOT''' ask the user for any information.
  
 
<br />
 
<br />
Line 38: Line 38:
 
==Requirements==
 
==Requirements==
 
<br />
 
<br />
* Your program should print rows of cars.  The color of the cars should be randomly generated.
+
* Your program should print rows of cars.  The color of the cars should be '''randomly generated'''.
* Your program uses the same car for each row
+
* Your program organizes the cars in rows, one above the other.  The car may or may not align vertically (the image above shows them aligned vertically).
* You are free to pick the shape of your car.  It must have at least 2 rectangles and at least two wheels.  You pick the shape that you like.
+
* You are free to design the shape of your car.  It must have at least 2 rectangles and at least two wheels.
* A given  car can have differently colored rectangles, or the same color for all its rectangles.  You decide.
+
* A given  car can have differently colored rectangles, or the same color for all its rectangles.  Your design decision.
 
* Cars are allowed to extend past the boundaries of the window.
 
* Cars are allowed to extend past the boundaries of the window.
 
* The message in the middle should appear inside a rectangle that hides the cars underneath it
 
* The message in the middle should appear inside a rectangle that hides the cars underneath it
 
* The message should be as centered in the rectangle as possible.
 
* The message should be as centered in the rectangle as possible.
* The message should be large enough to be easily readable
+
* The message should be large enough to be easily readable.
 +
* The actual text of the message is up to you.  It should be at least 5 characters long. 
  
 
<br />
 
<br />
Line 68: Line 69:
 
</source>
 
</source>
 
<br />
 
<br />
 +
* Do not hesitate to give your classes extra methods that can make your life easier in your main program.  For example, I used a '''setRandomColor()''' method for my Car class.  This way I can generate a black car, then ask it to pick its own random color:
 +
<br />
 +
:::<source lang="Python">
 +
      # generate a black car by default
 +
      c = Car( x, y, w, h, (0, 0, 0) )
 +
 +
      # make it pick a random color for itself
 +
      c.setRandomColor()
 +
</source>
  
 
=Submission=
 
=Submission=

Revision as of 09:03, 17 April 2014

--D. Thiebaut (talk) 21:28, 15 April 2014 (EDT)




This assignment is due Thursday night (4/24/14) at midnight. You can work in pair-programming mode on this homework.


CSC111 HappyEaster.png


Problem 1 (100 points)


  • 100 points = 70 points for program, 30 points for image
  • program: 70 = 20 points for documentation, 50 points for program structure, logic, and organization.


You have been hired for the summer by a company that makes wrapping paper. The company has a Web form where customers can pick different colors, a general theme, and a message to print in the middle of the page. Then a Python program generates an image that is printed by a large format printer.

The image above shows one particular output, for somebody who has selected Cars as the theme, Blue as the background, and "Happy Easter" as the message.

Your assignment


You must demonstrate that you can have the programming job by writing a program that generates a sample output, with a predefined color, a predefined scheme, and a predefined message. Your program will NOT ask the user for any information.


Submission


You must submit 2 files:

  • Your program, which should be called hw11a.py
  • An image of the output generated by your program. It should be called hw11a.png or hw11a.jpg


Requirements


  • Your program should print rows of cars. The color of the cars should be randomly generated.
  • Your program organizes the cars in rows, one above the other. The car may or may not align vertically (the image above shows them aligned vertically).
  • You are free to design the shape of your car. It must have at least 2 rectangles and at least two wheels.
  • A given car can have differently colored rectangles, or the same color for all its rectangles. Your design decision.
  • Cars are allowed to extend past the boundaries of the window.
  • The message in the middle should appear inside a rectangle that hides the cars underneath it
  • The message should be as centered in the rectangle as possible.
  • The message should be large enough to be easily readable.
  • The actual text of the message is up to you. It should be at least 5 characters long.


Hints


  • To set the color of the background, you can use the setBackground() canvas method:


win = GraphicsWindow(MAXWIDTH, MAXHEIGHT)
canvas = win.canvas()
    
canvas.setBackground( 0, 250, 250 )


  • Printing text can be used using two other canvas methods: setTextFont() and drawText():


canvas.setTextFont( 'arial', 40, 'bold' )
canvas.drawText( 100, 100,  "CSC111 Homework 11" )


  • Do not hesitate to give your classes extra methods that can make your life easier in your main program. For example, I used a setRandomColor() method for my Car class. This way I can generate a black car, then ask it to pick its own random color:


      # generate a black car by default
      c = Car( x, y, w, h, (0, 0, 0) ) 

      # make it pick a random color for itself
      c.setRandomColor()

Submission


Remember that you must submit 2 files, the program and a screen capture of your window. The submission URL is http://cs.smith.edu/~thiebaut/111b/submit11.php


Optional and Extra-Credits: Problem 2 (20 points)


CSCcarsAndTrucks.png


20 extra points = 10 points for program, 10 points for image
This second problem requires you to use two different types of cars. They should be different enough to be easily distinguished from one another.

The program must generate rows of cars, alternating between the two types of car. The first row should have cars of Type 1, the second row cars of Type 2, and continuing alternating between the two.

You need to submit two files, a program called hw11b.py and a screen copy of your image, called hw11b.jpg or hw11b.png (all lower-case). Submit both to the same URL as above.