CS每周1个project有感:美国读一般的大学也不容易

来源: wzg69 2018-11-14 09:48:26 [] [博客] [旧帖] [给我悄悄话] 本文已被阅读: 次 (39294 bytes)

这大学录取率是80%以上,Introduction to Object-Oriented Programming 学到这里才2个多月,还有一个月就结束了。最近大约1周一个project,真心不容易!看最近的一个要求

 

This problem set has two parts.  In the first part, you will be implementing part of a simple database for geocaches.  In the second part, you will be implementing a class reminiscent of Java's Scanner class.

Part 1

Geocaches

For the purposes of this assignment you do not need to know what geocaches are, but it can't hurt.  Geocaches are containers of various sizes that are hidden throughout the world.  Geocachers (such as me) are people who enjoy looking for geocaches. There is a free geocaching app available for smart phones.  There is also a website, https://www.geocaching.com/play/search, (Links to an external site.)Links to an external site. that we use to learn about geocaches in our area.  For example, there are more than 200 geocaches within two miles of MEB. 

Every geocache at geocaching.com has (among other things) a title, an owner, the GPS coordinates where it is located, a difficulty rating that describes how difficult the geocache is to find, and a terrain rating that describes how hard it is to travel to the hiding place. 

My geocaching name is "lesdubois", and I specialize in hiding "puzzle" caches.  To get the GPS coordinates of a puzzle cache, you have to first solve a puzzle.  To solve one of my puzzles, Digital Dilemma 2 (Links to an external site.)Links to an external site., the geocacher needs to write some simple computer programs.  If you're interested, the programs required are the right difficulty for CS 1410 students.

But I digress.

Getting Started

You will be completing the implementation of a program that I have started.  Your job will be to provide correct implementations and unit tests for two classes: Cache and CacheList.

Begin by running PS7Demo.jar.  Use the file chooser that pops up to navigate to and open the file caches.txt, which contains a list of geocaches.  (The list is a few years old, so some of the geocaches it contains no longer exist.)  The program will then open an application that lets you search through the contents of caches.txt.  When you have completed this assignment, your program should behave just like the demo program you have just run.

The four source files define five classes: Cache, CacheList, GeocacheBrowser, CacheTests, and  CacheListTests.  You should not modify GeocacheBrowser.  Unless you are curious, you do not need to understand it or even look at it.

GeocacheBrowser contains a main method.  Run it, and it will bring up the same application as the jar file.  Most everything will be blank, however, until you complete Cache and CacheList.

The application uses Cache objects (implemented by your Cache class) to represent individual geocaches.  It uses a CacheList object (implemented by your CacheList class) to keep track of, filter, and sort all the Cache objects.

Please read and follow the directions carefully.

Cache Class

The Cache class provides objects that represent information about a single geocache.  The class file contains complete specifications as well as a completed implementation for the toString method.  You should

  1. Read carefully through the entire class file.
     
  2. Create a complete set of unit tests for the Cache class.  I have created a test class called CacheTests that contains a sample test.  You should add your tests to this class.  The TAs and I will not help you with your Cache class implementation until you have completed this step!

    The key to testing class implementations is to realize that it is not usually possible to test each constructor and method in isolation.  For example, to test the getOwner() method of the Cache class, you must first use the constructor to create a Cache object.  

     
  3. Design a representation and then declare and document your instance variables.
     
  4. Implement the constructor.  Each line of the file caches.txt is an example of a string that the constructor should be able to take as a parameter.  (Hint:  Use the String split method.)
     
  5. Implement the methods (other than toString, which is already complete).
     
  6. Test/debug/modify your Cache and CacheTests classes until you are certain that the Cache class behaves according to its specifications.
     

CacheList Class

The CacheList class provides objects that represent collections of Caches as well as constraints on them.  The class file contains complete specifications as well as a partial implementation.  You should

  1. Read carefully through the entire class file.
     
  2. Create a complete set of unit tests for for the CacheList class.  I have created a test class called CacheListTests that contains a sample test.  You should add your tests to this class.  The TAs and I will not help you with your CacheList class implementation until you have completed this step!

    Keep in mind that it is not usually possible to test each constructor and method in isolation.  For example, to test the setTitleConstraint() method of the CacheList class, you must use the constructor to create a CacheList object, use setTitleConstraint(), and then call the select() method to see if the title constraint has the proper effect.

     
  3. Design a representation and then declare and document your instance variables.  Please note that I have already provided a key part of the representation.
     
  4. Complete the implementation of the constructor.  The file caches.txt is an example of the kind of file that the constructor should be able to process.  Please note that I have included code that shows how to sort a list of Cache objects.
     
  5. Implement the methods.  Please note that the partial implementation of getOwners I have provided shows how to sort a list of Strings.
     
  6. Test/debug/modify your CacheList and CacheListTests classes until you are certain that the CacheList class behaves according to its specifications.
     

GeocacheBrowser

If you have correctly implemented Cache and CacheList, your GeocacheBrowser should behave identically to the example implementation.  If it doesn't, the problem is with either Cache or CacheList.

 

Part 2

MyScanner

In this part of the problem set, you are to design, implement, document, and test a class that provides objects that have a subset of the capabilities of Scanners.  Your class must:

  • Be called MyScanner and be in a package called scan
  • Provide a constructor that takes a String as a parameter
  • Provide four methods:
    1. hasNext(), which takes no parameters and returns a boolean
    2. next(), which takes no parameters and returns a String
    3. hasNextInt(), which takes no parameters and returns a boolean
    4. nextInt(), which takes no parameters and returns an int
  • Not use Scanner in its implementation!

A MyScanner should behave just like a Scanner would if you only used the Scanner's String constructor and its hasNext(), next(), hasNextInt(), and nextInt() methods.  Be sure that you understand exactly how Scanners behave, including the circumstances in which exceptions are thrown.  Don't simply assume you know how those methods interact.  For example, hasNextInt() doesn't report whether there is an integer token somewhere in the Scanner; it reports whether the next token can be parsed as an int by Integer.parseInt().  You should read the relevant parts of the Scanner documentation (Links to an external site.)Links to an external site. and (probably more importantly)  experiment with Scanners.

Since there is no close() method, none of the MyScanner methods should ever throw an IllegalStateException.  However, in the right circumstances some of the MyScanner methods should throw a java.util.NoSuchElement exception and/or a java.util.InputMismatchException.

Be sure to test your MyScanner class thoroughly.  Put your unit tests in a class MyScannerTests in the scan package.  If I were you, I would write thorough test cases for the Scanner class.  Then, when I was sure that my tests cases were correct and complete, I would do a global replace of "MyScanner" for "Scanner".  But that's just me.

Hint:  Here is a bit of code that decomposes a string into an array of tokens:

String[] tokens = s.trim().split("\\s+");

Here's how it works.  It first "trims" the string, which removes all leading and trailing white space.  It then splits the string into tokens.  The parameter that is passed to split says that tokens will be separated by one or more white space characters.

Submitting

Keep in mind that the CPM validator does not test or grade your program.  It only checks that you have named everything as specified.  Don't ignore validation errors, as they will make it difficult to grade your program.

Don't forget to submit your solution.  You can submit a solution as many times as you like, but we will only grade your most recent submission.

 

Rubric

P7 Rrubric
P7 Rrubric
Criteria Ratings Pts
Passes 20 tests in CacheGrader
 
 
 
20.0 pts
Full Marks
 
 
0.0 pts
No Marks
 
20.0 pts
Passes 20 tests in CacheListGrader
 
 
 
20.0 pts
Full Marks
 
 
0.0 pts
No Marks
 
20.0 pts
Passes 20 tests in MyScannerGrader
 
 
 
20.0 pts
Full marks
 
 
0.0 pts
No marks
 
20.0 pts
Instance variables are private
 
 
 
2.0 pts
All
 
 
1.0 pts
Some
 
 
0.0 pts
None
 
2.0 pts
Instance variables are non-static
 
 
 
2.0 pts
All
 
 
1.0 pts
Some
 
 
0.0 pts
None
 
2.0 pts
Instance variables are commented
 
 
 
2.0 pts
All
 
 
1.0 pts
Some
 
 
0.0 pts
None
 
2.0 pts
Comprehensive tests provided in CacheTests
 
 
 
4.0 pts
Yes
 
 
2.0 pts
Partially
 
 
0.0 pts
No tests
 
4.0 pts
Comprehensive tests provided in CacheListTests
 
 
 
10.0 pts
Yes
 
 
5.0 pts
Partially
 
 
0.0 pts
No tests
 
10.0 pts
Comprehensive tests provided in MyScannerTests
 
 
 
10.0 pts
Yes
 
 
5.0 pts
Partially
 
 
0.0 pts
No tests
 
10.0 pts
Student made an effort
 
 
 
10.0 pts
Yes
 
 
0.0 pts
No
 
10.0 pts
Total Points: 100.0

所有跟帖: 

美国大学教育水平确实很高,尤其这种project,很锻炼人的 -cutedolphin- 给 cutedolphin 发送悄悄话 (0 bytes) () 11/14/2018 postreply 09:51:26

不懂,学就是了。不然上大学干什么。 -篱笆08- 给 篱笆08 发送悄悄话 篱笆08 的博客首页 (0 bytes) () 11/14/2018 postreply 09:52:29

要不为啥说米国ABET acredited毕业的工程师就有保障,公司就可放心雇用呢? ^_^ -白色非色- 给 白色非色 发送悄悄话 白色非色 的博客首页 (0 bytes) () 11/14/2018 postreply 10:11:06

工程师 != programmer -iamagg- 给 iamagg 发送悄悄话 iamagg 的博客首页 (0 bytes) () 11/14/2018 postreply 10:41:46

米国大学大部分的CS都在工程学院里,拿的是ABET accredited 的学位,当然,如有疑问,可以到ABET的网站查 -白色非色- 给 白色非色 发送悄悄话 白色非色 的博客首页 (0 bytes) () 11/14/2018 postreply 11:26:35

你家牛娃又出去上大学课啦? -backyardfun- 给 backyardfun 发送悄悄话 (185 bytes) () 11/14/2018 postreply 10:38:24

这些是侄子的 -wzg69- 给 wzg69 发送悄悄话 wzg69 的博客首页 (209 bytes) () 11/14/2018 postreply 10:42:37

对于从小玩编程的不是问题。所以入了同一个大学,学生差别还是挺大的 -dengGGdeng- 给 dengGGdeng 发送悄悄话 (0 bytes) () 11/14/2018 postreply 10:58:21

他的问题是不想花时间 -wzg69- 给 wzg69 发送悄悄话 wzg69 的博客首页 (265 bytes) () 11/14/2018 postreply 11:25:24

是,大学生要自律,没了这个毁所有啊 -dengGGdeng- 给 dengGGdeng 发送悄悄话 (0 bytes) () 11/14/2018 postreply 11:41:50

俺娃期中考试完,老师说全班分数20几到90几不等,水平差别好大 -新年好运- 给 新年好运 发送悄悄话 (0 bytes) () 11/14/2018 postreply 15:16:47

cs从小起步的太多 -wzg69- 给 wzg69 发送悄悄话 wzg69 的博客首页 (44 bytes) () 11/14/2018 postreply 16:24:37

请您先登陆,再发跟帖!

发现Adblock插件

如要继续浏览
请支持本站 请务必在本站关闭/移除任何Adblock

关闭Adblock后 请点击

请参考如何关闭Adblock/Adblock plus

安装Adblock plus用户请点击浏览器图标
选择“Disable on www.wenxuecity.com”

安装Adblock用户请点击图标
选择“don't run on pages on this domain”