Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
CS 161 -  Fall 2016 
Assignments & Labs 
 
                     
Assignment  Description      Due Date 
Assign #1  pg 52    Exercises 1.3, 1.14, 1.15, 1.17, 1.20  Sept 30 
Worksheet #1              Java code and Answers to questions  Oct 3 
Lab #1  pg 56    Project 1.10   (initials)  Oct 5 
Assign #2  pg 106  Exercises 2.4, 2.7, 2.9, 2.10, 2.17  Oct 7 
 
Worksheet #2              Java code and Answers to questions  Oct 10 
Lab #2  pg 110  Project  2.14  (Snowman)  Oct 12 
Assign #3  pg 155  Exercises 3.1, 3.2, 3.5, 3.7, 3.9     Oct 14 
 
Worksheet #3    Java code and Answers to questions  Oct 17 
Lab #3  pg 157  Project 3.1** (User name)   Oct 19 
Assign #4  pg 200  Exercises 4.1, 4.2, 4.5 & SR 4.10, 4.13 Oct 21 
 
Worksheet #4              Java code and Answers to questions  Oct 24  
Lab #4  pg 202  Project 4.4**  (Dog class)  Oct 26 
Assign #5  pg ??     SelfReview  4.20,4.24,4.30,4.32,4.34 Oct 28 
 
Worksheet #5              Java code and Answers to questions  Oct 31 
Lab #5  pg 203  Project 4.12**          (Crayons )  Nov 2 
Assign #6   pg 201  Exercises  4.6, 4.7, 4.8, 4.10, 4.11  Nov 4 
 
Worksheet #6              Java code and Answers to questions  Nov 7 
Lab #6  pg 263  Projects 5.1 and 5.2 combined **  Nov 9 
       (Gregorian calendar) 
Assign #7  pg 260  Exercises 5.1, 5.4, 5.9, 5.13 ,5.15  Nov 14 
 
Worksheet #7    Java code and Answers to questions  Nov 14 
Lab #7  pg 265  Project 5.12  ** (Golf)   Nov 16 
Assign #8  pg 294  Exercises 6.1, 6.7, 6.10, 6.14, 6.16  Nov 18 
 
Worksheet #8              Java code and Answers to questions  Nov 21 
Lab #8  pg 298  Project 6.18 ** (Quilt)   Nov 23 
Assign #9  pg 433  Exercises 8.1, 8.2, 8.3,8.4,8.7   Nov 28 
 
Worksheet #9              Java code and Answers to questions  Nov 28 
Lab #9  pg 435   Project 8.1  ** (Array)   Nov 30 
Extra Credit Lab pg 299   Project 6.23  (dialog boxes)  Dec 2 
 
FINAL EXAM:      Monday,  Dec 5th    8:00  – 9:50 am    MKH 203   
All assignments must be typed using a word processor. 
 
**  Additional Instructions All labs**** 
 
TURN IN:    
   1)  A printed copy of your code with the appropriate header – see “header” instructions below 
   2)  An electronic copy of your code, in a folder, to the class Drop Box subdirectory 
(M:\Computer Systems\DodiCoreson\Turn In Assignments\CS161\Lab??).  Name 
your folder LastNameX_L?, where X is the first letter of your first name, and ? is 
replaced by the lab number.  For instance:  John Q Adams would name his lab 2  folder: 
AdamsJ_L2. 
 
HEADER:  Be sure to put a proper “header” at the top of your file(s) – There is a sample 
on the last page of these instructions as well as a file named:  header.java in the 
dropbox.  All files must have this header!! 
 
TEST ORACLE  (unless otherwise noted below…)  
    Be sure to put a “Test Oracle” in your header:  (a Test Oracle is a chart that lists possible 
inputs, and the output you would expect from your code - for that input)   
          The Test Oracle should be created before you write the code. Your program, when 
done, should produce the same results.  Caution:  if you write your Test Oracle AFTER 
writing the code  (ie – use the running code to create the output values) you will not be 
able to tell if your code is producing correct results. 
 
 
LAB  DETAILS: 
Lab #1:  Initials:  Instead of printing your initials, you may choose to print any picture that can 
be created with System.out.println() statements. 
 
Lab #2 – Snowman:  Be sure to turn in and print out both your .java file and your .html file. 
 Also:  change the color of the “ground” to be either green or orange. 
 
Lab #3 – Your Test Oracle should list several first and last names, and the corresponding 
username your program should generate.  (you may use XX for the random integers)   
For example: 
                         First Name        Last Name         UserName      
   Daniel  Wilson  dwilsoXX 
  Jonathan    Anderson janderXX 
  Betsy  Cartright bcartrXX  
 
Lab #4 – Write your own class Dog, and a driver class Kennel 
 A.   in your Dog class 
1)  create a method called PeopleYears(), which calculates and returns the age of 
the dog in “people years”  (DogAge * 7).   
2)  use only two instance variables: Name and Age 
3)  create one constructor that receives two arguments: a string and an integer 
   B.  In your driver class (Kennel): 
a) Declare at least 4 dog objects. 
b) Update three different  instance variables (different objects)  using “setter”  
methods 
c) Call at least two “getter” methods 
d) Call the PeopleYears method for each object  
e) Print the description of each Dog object you have created (using your 
toString() method). 
C.  Create a test oracle for the method PeopleYears(). 
 
 
Lab #5 – Crayons– Use the example that starts on pg 184 in your textbook as a place to start. 
(listing #4.7: the classes Splat, SplatPanel and  Circle) 
   You will write three separate classes: 
 
1)    A “driver”  program called CrayonBox  
a)   Create the frame, with the words “Crayon Box” in the Title Bar 
b)   Create a Crayon Panel object and call the constructor for Crayon Panel 
c)   Add the CrayonPanel object to the Frame 
 
2)  A separate panel class called CrayonPanel  
a)   Will instantiate at least 6 Crayon objects 
b)   With each object, call the Draw() method to draw  it on the screen. 
c)   Draw a box over the crayons. 
d)   Draw your name somewhere on the screen 
 
3)  A class called Crayon,  
a)  The constructor will set the height, color and X,Y coordinates  for each Crayon 
object.   
b)  The class Crayon will need the method Draw to draw each Crayon object on the 
screen.  The Draw() method will use the height, and  X,Y coordinates for the 
Crayon objects’ position on the screen.   
c)  Write setter and getter methods for each instance variable  
 
4)  No test oracle required 
5)  Extra credit:  create a method called RandomColor which returns a Color object.  
The method will randomly generate the red, green and blue values for the Color.  
Write a setter method that will call Random Color to set the Color for a crayon 
 
Lab #6 – Gregorian Calendar – Leap years…..Combine the instructions for programming 
projects 5.1 and 5.2.  Your program will include a flag loop (not a sentinel loop) that 
will allow the user to continue entering years until they say they are done.  You will 
also include a verification of input loop that will produce an error message if the year 
entered is less than 1582, and ask for another input.  When you ask for input from the 
user, be sure to tell the user what years are acceptable.  After each year is entered, 
your program should produce a message telling the user if the year was a leap year or 
not. 
Test oracle:  show the expected output for a number of different years: for example-  
before 1582, after 1582 that are leap years, after 1582 that are not leap years, and after 
1582 that are also century marks (1900, 2000…) 
Lab #7 –GOLF”   Create a Text file with golf scores.  Each line in the file will contain five 
integer values – the first value is par for that hole, the next four values are scores for 
each of the four golfers.  The file will contain a total of 18 lines (18 holes).  DO NOT 
USE an ARRAYLIST for this lab. Your program will: 
1) read information from the file, add the scores from each hole for each golfer 
2) determine each golfers final score and print those scores. 
3) determine the winner of this golf game and print a message saying who won  
4)  produce a table showing how each golfer’s score  compares to par. (ie:  5 over 
par, 2 under par… etc.) 
5)  Test oracle will use a ‘sample” file – of only 3 or 4 holes of golf… to test for 
accuracy of your code. 
6) Extra Credit:  create the file you will be reading from by randomly generating 
the integers needed and writing them to the file. See page 555 for an example 
of writing to a file.  Be sure to turn in the printed code for this program also, 
and Octk it as “Extra Credit” 
 
Lab #8 – QUILT – You must create a Pattern Class and declare two objects of that class. The 
constructor for this class will accept a parameter that sets a characteristic of the object 
(like the color and width). Alternate those objects when drawing the quilt.  Make sure 
that your quilt contains at least 5 blocks across and 7 down. (your grid must be at least 
5 x 7 squares). Your Pattern class should include a method called  Draw() that draws 
the pattern on the screen at a specific location.  The Draw() method must receive the x 
and y coordinates of the location.  You must use nested loops to draw the quilt.  Test 
oracle not needed.  (Hint:  Use the Splat, SplatPanel and  Circle classes as an 
example of how to write a Quilt, QuiltPanel and Pattern classes for this project. 
 
Lab #9 – ARRAY: Generate 1000 random integers in the range 0-50.  Use an array to hold the 
count of how many times each of the values in the range comes up as a random 
number. (do not use an array of 1000!)  Print the contents of the array in a table that 
lists the value (0-50) and then the contents of that array element. 
             Test oracle: generate 25 random integers in the range 0-10 and print how many times 
each value was generated 
 
SAMPLE  HEADER 
 
                     (everything in parenthesis should be replaced with your own information) 
// ************************************************************** 
//  Name: (Your Name)         Folder Name:(name of folder in dropbox) 
//  CS161  Fall 2016             Lab #: (1,2,3,4,5 ...) 
//  Class time: (Mon/Wed/Fri 8:00)  
//  Date:  (date done - ready to turn in) 
//  Program Name: (Name of file to be graded  ) 
//  Program Description:       ( What does this program do?) 
//                                             ( Test Oracle goes here! ) 
//********************************************************************* 
public class NAME_OF_YOUR_FILE 
{    public static void main(String[] args) 
         {   // your code goes here……make sure your code will compile before you turn it in!    
         }                // end main 
}                     // end class