CS61B, Fall 2013 Project #3: Graphs (version 4) P. N. Hilfinger

Similar documents
, has the form T i1i 2 i m. = κ i1i 2 i m. x i1. 1 xi2 2 xim m (2)

1 Executing the Program

CS61B, Fall 2014 Project #1 (revision 4) P. N. Hilfinger

CS 356, Fall 2018 Data Lab (Part 2): Manipulating Bits Due: Mon, Sep. 17, 11:59PM

Programming Standards: You must conform to good programming/documentation standards. Some specifics:

Basic Compilation Control with Make

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger

CS 356, Fall 2018 Data Lab (Part 1): Manipulating Bits Due: Wednesday, Sep. 5, 11:59PM

CS164: Programming Assignment 2 Dlex Lexer Generator and Decaf Lexer

SFU CMPT 379 Compilers Spring 2018 Milestone 1. Milestone due Friday, January 26, by 11:59 pm.

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger

CS ) PROGRAMMING ASSIGNMENT 11:00 PM 11:00 PM

Programming Assignment #2

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger

Veristruct: An IEEE (Verilog 1995) Preprocessor

Java Program Structure and Eclipse. Overview. Eclipse Projects and Project Structure. COMP 210: Object-Oriented Programming Lecture Notes 1

3. When you process a largest recent earthquake query, you should print out:

CS3114 (Fall 2013) PROGRAMMING ASSIGNMENT #2 Due Tuesday, October 11:00 PM for 100 points Due Monday, October 11:00 PM for 10 point bonus

ICOM 4015 Advanced Programming Laboratory. Chapter 1 Introduction to Eclipse, Java and JUnit

C++ Basics. Lecture 2 COP 3014 Spring January 8, 2018

Program 1: Generating Summation Puzzles

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger

CS : Programming for Non-majors, Fall 2018 Programming Project #2: Census Due by 10:20am Wednesday September

Objectives. In this chapter, you will:

Maemo Diablo GNU Make and makefiles Training Material

We d like to hear your suggestions for improving our indexes. Send to

CMSC 201 Spring 2016 Lab 08 Strings and File I/O

PART 7. Getting Started with Excel

Chapter 2. Lexical Elements & Operators

Berkeley Practice Contest Fall P. N. Hilfinger

Full file at

AN OVERVIEW OF C. CSE 130: Introduction to Programming in C Stony Brook University

Warm-up sheet: Programming in C

Some Patterns for CS1 Students

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

int n = 10; int sum = 10; while (n > 1) { sum = sum + n; n--; } cout << "The sum of the integers 1 to 10 is " << sum << endl;

BASIC ELEMENTS OF A COMPUTER PROGRAM

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger

Project #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently.

CS11 Advanced C++ Fall Lecture 4

Classes, interfaces, & documentation. Review of basic building blocks

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

CS 4218 Software Testing and Debugging Ack: Tan Shin Hwei for project description formulation

Chapter 2: Basic Elements of C++

Computer Science 501 Data Structures & Algorithms The College of Saint Rose Fall 2014

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

1 Lecture 3: Python Variables and Syntax

CSE20 : Lab #4 - Data Types

You must bring your ID to the exam.

Project 1 Computer Science 2334 Spring 2016 This project is individual work. Each student must complete this assignment independently.

CS 134 Programming Exercise 2:

Identifiers. Identifiers are the words a programmer uses in a program Some identifiers are already defined. Some are made up by the programmer:

ECEn 424 Data Lab: Manipulating Bits

GSAK (Geocaching Swiss Army Knife) GEOCACHING SOFTWARE ADVANCED KLASS GSAK by C3GPS & Major134

CS 2505 Fall 2013 Data Lab: Manipulating Bits Assigned: November 20 Due: Friday December 13, 11:59PM Ends: Friday December 13, 11:59PM

Chapter 2 The SAS Environment

boolean, char, class, const, double, else, final, float, for, if, import, int, long, new, public, return, static, throws, void, while

6.170 Laboratory in Software Engineering Java Style Guide. Overview. Descriptive names. Consistent indentation and spacing. Page 1 of 5.

CS52 - Assignment 8. Due Friday 4/15 at 5:00pm.

Data Lab: Manipulating Bits

VARIABLES. 1. STRINGS Data with letters and/or characters 2. INTEGERS Numbers without decimals 3. FLOATING POINT NUMBERS Numbers with decimals

CSE Theory of Computing Fall 2017 Project 1-SAT Solving

Assignment #1: /Survey and Karel the Robot Karel problems due: 1:30pm on Friday, October 7th

Mehran Sahami Handout #7 CS 106A September 24, 2014

printf( Please enter another number: ); scanf( %d, &num2);

CMSC 201 Fall 2017 Lab 12 File I/O

CS 215 Software Design Homework 3 Due: February 28, 11:30 PM

Programming Project 5: NYPD Motor Vehicle Collisions Analysis

CSE 11 Style Guidelines

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger

CMPSCI 187 / Spring 2015 Hanoi

ASSIGNMENT 5 Objects, Files, and a Music Player

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017

UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4500/8506 Operating Systems Summer 2016 Programming Assignment 1 Introduction The purpose of this

ECE 122 Engineering Problem Solving with Java

Announcements. Last modified: Thu Nov 29 16:15: CS61B: Lecture #40 1

North Carolina Community Colleges Business Intelligence Reporting System

In either case, remember to delete each array that you allocate.

CSSE2002/7023 The University of Queensland

Introduction to Programming System Design CSCI 455x (4 Units)

CS : Programming for Non-majors, Summer 2007 Programming Project #2: Census Due by 12:00pm (noon) Wednesday June

CMPSCI 187 / Spring 2015 Sorting Kata

Bentleyuser.dk Årsmøde 2012 Nordic Civil 2012

Assignment #1: and Karel the Robot Karel problems due: 3:15pm on Friday, October 4th due: 11:59pm on Sunday, October 6th

Scripting Languages. Diana Trandabăț

Chapter 2 Basic Elements of C++

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

CS 2604 Minor Project 1 Summer 2000

1 Lexical Considerations

EDIABAS BEST/2 LANGUAGE DESCRIPTION. VERSION 6b. Electronic Diagnostic Basic System EDIABAS - BEST/2 LANGUAGE DESCRIPTION

Lab 03 - x86-64: atoi

Lecture 6. Instructor: Craig Duckett

CSCE 120: Learning To Code

Intro. Scheme Basics. scm> 5 5. scm>

Hands on Assignment 1

Lesson 1: Creating and formatting an Answers analysis

hw6, BFS, debugging CSE 331 Section 5 10/25/12 Slides by Kellen Donohue

15-323/ Spring 2019 Project 4. Real-Time Audio Processing Due: April 2 Last updated: 6 March 2019

EE 422C HW 6 Multithreaded Programming

Transcription:

CS61B, Fall 2013 Project #3: Graphs (version 4) P. N. Hilfinger Due: Monday, 9 December 2013 1 Introduction For this final project, you will be writing a library package to provide facilities for manipulating graphs, plus two clients that use the package. The package must be general: no specifics of either client may find their way into the code for the graph package. We will check that by running our own clients against your package. That is, in contrast to past projects where we didn t care how you arranged the internals of your program as long as it functioned according to the specification, in this case, part of the project code the API for the graph package will be set in stone. 2 Client: Make We ve been using the Make program (specifically, GNU make) in most programming assignments this semester. For this project, we are going to implement a much stripped-down version. An input file ( makefile ) will consist of rules that indicate that one set of objects (called targets) depends on another set (called prerequisites). Any line that starts with # or contains only tabs and blanks is ignored. For other lines, the syntax is T: P 1 P 2 P m command set where m 0, and T starts in the first column. We ll call the first line of the rule its header. Each T or P j is a string of non-whitespace characters other than :, =, #, or \. The command set consists of zero of more lines that begin with a blank or tab. Command sets with no lines in them are called empty. The commands for one rule end at the next rule (or the end of file). 2.1 Interpreting a Makefile In general, the program is given a makefile in the format just described, plus a set of targets that it is to rebuild, and information about which objects currently exist and when they were last built. (In real life, Make finds out the latter for itself, by querying the file system. We will stop short of this level of realism.) The program reads the Makefile sequentially. After reading all the definitions, the program considers all the targets it has been asked to rebuild, and figures out which commands (if any) must be executed to rebuild each target, and in what order. For a target T, If the makefile does not have a rule with T as the target, and T does not currently exist, there is an error. If T does exist, it is considered built. 1

Project #3 2 Otherwise, Make considers all the headers in the makefile whose target is T and collects the set of all prerequisites listed in those headers. It first builds all of these prerequisites, applying the procedure being described here. Next, if T does not exist, or if T is older than at least one of its prerequisites, Make executes the non-empty commands set from one of these rules, and then sets the creation time of T to be larger than that of any existing object (so that T is now the youngest object). It is an error if there is more than one non-empty set of commands for a target. Make never rebuilds something unnecessarily. For this assignment, executing commands simply means printing them verbatim. As usual, in response to input errors (in format, for example), you should output an error message on the standard error output and exit with a non-zero exit code. Do not output to the standard error output otherwise. Errors include missing prerequisites with no build instructions, attempting to build a target that has more than one non-empty commands set, syntax errors in the input files (see also 2.2), and circular dependencies. 2.2 Running Make To run the Make client, a user will type java make.main [ -f MAKEFILE ] [ -D FILEINFO ] [ TARGET... ] where [...] indicates an optional argument. MAKEFILE (default Makefile) is the name of the makefile. FILEINFO (default fileinfo) describes the current existing objects and their ages (see below). Each TARGET is processed as a target in order (if there are no targets, use the target(s) of the first rule in the makefile as the default). The FILEINFO argument is a file containing lines of the form NAME CHANGEDATE where CHANGEDATE is an integer indicating a time (the larger the time, the younger the named object). On a Unix system, this would be the number of seconds since the Epoch (the beginning of 1 January 1970), not counting leap seconds (making 2038 (2 3 1 seconds past the Epoch) the Unix Y2K year). However, for us, the only thing that matters is that larger is later. The first line of the FILEINFO file contains only a date (that is, an integer), indicating the current time, and larger than any CHANGEDATE in the file. 3 Client: Trip finder I suspect you all have or have used some sort of GPS device by now, or gotten directions from the Google tm map service. Such systems know about a network of roads, and given two end points (and perhaps some waypoints in between) will pick out a shortest route. This next client will be a stripped-down version. Specifically, this program, given a map and a request a sequence of two or more points on the map will produce a shortest route from the first point to the second, third, and so forth.

Project #3 3 The map file will be in free format (a sequence of words containing no whitespace and separated by whitespace blanks, tabs, newlines, etc.). Information comes in two forms: location entries, introduced by the letter L, and road entries entries, introduced by the letter R. Location entries have the form L C X Y where C designates a place and X and Y are floating-point numbers. This means that the place named C is at coordinates (X,Y ) (we re sort of assuming a flat earth here.) There may only be one location entry for any given C. Distance entries have the form R C 0 N L D C 1 where each C i designates a place, N is the name of a road L is a numeric distance (a floating-point number), and D is one of the strings NS, EW, WE, SN. Each C i must be declared in a previous location entry. For example, the entry R Montara US_1 56.0 NS Santa_Cruz would mean that US 1 runs North to South from Montara to Santa Cruz, for a distance of 56.0 miles, and that there are no map points in between (I guess we have a rather idiosyncratically sparse map). Our road connections will all be two way, so the sample entry also indicates a South to North-running route (SN) from Santa Cruz to Montara. Requests will come from a file each of whose lines contains the names of two or more points on the map, separated by commas and whitespace. For example, Berkeley, San_Francisco, Santa_Cruz Santa_Cruz, San_Jose, Stockton Strip any whitespace from before and after each of these three strings. In response, your program is supposed to print out a route in this format for each request: From Berkeley: 1. Take University_Ave west for 0.1 miles. 2. Take Martin_Luther_King_Jr Way south for 1.2 miles. 3. Take Ashby_Ave west for 1.8 miles. 4. Take I-580 west for 1.0 miles. 5. Take I-80 west for 8.4 miles to San_Francisco. 6. Take US-101 south for 34.5 miles. 7. Take CA-85 south for 13.3 miles. 8. Take CA-17 south for 22.2 miles. 9. Take CA-1 north for 1.0 miles to Santa_Cruz.

Project #3 4 When two adjacent segments use the same road with the same orientation (NS, EW), join them into one segment. So instead of printing print 3. Take Ashby_Ave west for 1.0 miles. 4. Take Ashby_Ave west for 0.8 miles. 5.... 3. Take Ashby_Ave west for 1.8 miles. 4.... As usual, in response to input errors (in format, for example), you should output an error message on the standard error output and exit with a non-zero exit code. Do not output to the standard error output otherwise. 3.1 Running Trip Finder To run the Tripfinder client, a user will type java trip.main [ -m MAP ] [ -o OUT ] [ REQUESTS ] MAP (default Map) is the name of the file containing the map data. REQUESTS (default, the standard input) contains the requests. OUT (default, the standard output) receives the solution. 4 The Graph Package You should implement these two clients using a graph package whose interface we ve supplied. The package graph will export several classes (marked public in the skeleton) and no other public classes. You can add classes to the package as long as they are not public. You can add members to the public classes, as long as they are overridings of public methods or are not public or protected. You can change methods, but not the signatures (types of parameters and return values) of public or protected methods. We will test your graph package separately, exercising methods that might not be used by either of the clients you implement, so unit tests will be particularly useful. Likewise, we will test your clients using our graph package, so that your clients must rely only on the published spec, and not on any special behavior of your particular implementation. 5 Your Task The staff directory will contain skeleton files for this project in proj3. Please read General Guidelines for Programming Projects. Be sure to include tests of your program (that is part of the grade). The makefile we provide has a convenient target for running such tests. Our skeleton directory contains a couple of trivial tests, but these do not constitute an adequate set of tests! Make up your

Project #3 5 tests ahead of time and update your makefile to run them. To help with testing and debugging, we will provide our own version of the program, so that you can test your program against ours (we ll be on the lookout for illegal moves). More details will follow. We will expect your finished programs to be workmanlike, and of course, will enforce the mechanical style standards. Make sure all methods are adequately commented meaning that after reading the name, parameters, and comment on a method, you don t need to look at the code to figure out what a call will do. Don t leave debugging print statements lying around. In fact, don t use them; learn to use the debugger (either gjdb or that of Eclipse or your favorite Java-system vendor). The nature of the graph package is such that you ll probably want to do extensive JUnit testing on it. Always feel free to add private setup procedures for testing purposes only that set up conditions (such as graphs) that are used by several different tests. Our testing of your projects (but not our grading!) will be automated. The testing program will be finicky, so be sure that make check runs your tests. 6 Advice Use svn or the hw command regularly. This provides backup. It s the safest way to transport things from a copy of your project on a local computer to (commit) and from (update) the instructional machines. Frequent commits will limit the amount of work you have to do when a file gets messed up. Use svn status or hw status to check for files that should be added and to make sure all necessary commits have been done. Use of make style not only encourages proper formatting, but also shows you missing documentation or left-over internal comments that might indicate work that still needs to be done, and can find certain error-prone constructs or bad practices. 7 Corrections 1. The format for distance entries for the trip application should be R C 0 N L D C 1 2. There was a stray paragraph about errors from project 2 that crept in. It has been removed. 3. In one example, the initial R was missing from the description of a road segment from Montara to Santa Cruz. 4. The sample output was changed to repeat city and road names literally (including underscores). 5. The proper statement of what you may change in the graph package is:

Project #3 6 The package graph will export several classes (marked public in the skeleton) and no other public classes. You can add classes to the package as long as they are overridings of public methods or are not public or protected. You can add members to the public classes, as long as they are not public or protected or are overridings of public methods. You can change methods, but not the signatures (types of parameters and return values) of public or protected methods.