Ascii Art Capstone project in C

Similar documents
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Assignment #5: Rootkit. ECE 650 Fall 2018

ROCK-POND REPORTING 2.1

Lab 1 - Calculator. K&R All of Chapter 1, 7.4, and Appendix B1.2

Lab 1 - Calculator. K&R All of Chapter 1, 7.4, and Appendix B1.2 Iterative Code Design handout Style Guidelines handout

Project #1 - Fraction Calculator

INSTALLING CCRQINVOICE

LAB 7 (June 29/July 4) Structures, Stream I/O, Self-referential structures (Linked list) in C

Managing Your Access To The Open Banking Directory How To Guide

Access the site directly by navigating to in your web browser.

These tasks can now be performed by a special program called FTP clients.

Programming Project: Building a Web Server

COP2800 Homework #3 Assignment Spring 2013

Preparation: Follow the instructions on the course website to install Java JDK and jgrasp on your laptop.

Reading and writing data in files

Using UB Stream and UBlearns

ClassFlow Administrator User Guide

Type: System Enhancements ID Number: SE 93. Subject: Changes to Employee Address Screens. Date: June 29, 2012

State Assessment Program Indiana Released Items Repository Quick Guide

Importing data. Import file format

Faculty Textbook Adoption Instructions

Lab 5 Sorting with Linked Lists

C++ Reference Material Programming Style Conventions

Copyrights and Trademarks

Integrating QuickBooks with TimePro

Interfacing to MATLAB. You can download the interface developed in this tutorial. It exists as a collection of 3 MATLAB files.

REFWORKS: STEP-BY-STEP HURST LIBRARY NORTHWEST UNIVERSITY

Working With Audacity

McGill University School of Computer Science COMP-206. Software Systems. Due: September 29, 2008 on WEB CT at 23:55.

TechSmith Relay 5.1.5

MyUni Adding Content. Date: 29 May 2014 TRIM Reference: D2013/ Version: 1

Getting Started with the Web Designer Suite

UiPath Automation. Walkthrough. Walkthrough Calculate Client Security Hash

Qualtrics Instructions

UiPath Automation. Walkthrough. Walkthrough Calculate Client Security Hash

TUTORIAL --- Learning About Your efolio Space

Proper Document Usage and Document Distribution. TIP! How to Use the Guide. Managing the News Page

Using the Swiftpage Connect List Manager

Create Your Own Report Connector

Lab 0: Compiling, Running, and Debugging


RISKMAN REFERENCE GUIDE TO USER MANAGEMENT (Non-Network Logins)

How To enrich transcribed documents with mark-up

Relius Documents ASP Checklist Entry

Date: October User guide. Integration through ONVIF driver. Partner Self-test. Prepared By: Devices & Integrations Team, Milestone Systems

Entering an NSERC CCV: Step by Step

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

OASIS SUBMISSIONS FOR FLORIDA: SYSTEM FUNCTIONS

You may receive a total of two GSA graduate student grants in your entire academic career, regardless of what program you are currently enrolled in.

Using the Swiftpage Connect List Manager

I - EDocman Installation EDocman component EDocman Categories module EDocman Documents Module...2

Adverse Action Letters

Summary. Server environment: Subversion 1.4.6

Managing User Accounts

Uploading Files with Multiple Loans

Please contact technical support if you have questions about the directory that your organization uses for user management.

Municode Website Instructions

Lesson 4 Advanced Transforms

SmartPass User Guide Page 1 of 50

BI Publisher TEMPLATE Tutorial

USO RESTRITO. SNMP Agent. Functional Description and Specifications Version: 1.1 March 20, 2015

MySqlWorkbench Tutorial: Creating Related Database Tables

Using CppSim to Generate Neural Network Modules in Simulink using the simulink_neural_net_gen command

CS1150 Principles of Computer Science Introduction (Part II)

INSERTING MEDIA AND OBJECTS

TRAINING GUIDE. Lucity Mobile

FIT 100. Lab 10: Creating the What s Your Sign, Dude? Application Spring 2002

Access 2000 Queries Tips & Techniques

Systems & Operating Systems

Constituent Page Upgrade Utility for Blackbaud CRM

Web of Science Institutional authored and cited papers

Introduction to Adobe Premiere Pro for Journalists:

$ARCSIGHT_HOME/current/user/agent/map. The files are named in sequential order such as:

TRAINING GUIDE. Overview of Lucity Spatial

Exporting and Importing the Blackboard Vista Grade Book

Courseware Setup. Hardware Requirements. Software Requirements. Prerequisite Skills

Click Studios. Passwordstate. RSA SecurID Configuration

TaiRox Mail Merge. Running Mail Merge

Project 4: System Calls 1

Quick Installation Guide

Homework: Populate and Extract Data from Your Database

Campuses that access the SFS nvision Windows-based client need to allow outbound traffic to:

TN How to configure servers to use Optimise2 (ERO) when using Oracle

Chapter 1 Getting Started

Populate and Extract Data from Your Database

The Reporting Tool. An Overview of HHAeXchange s Reporting Tool

Eastern Mediterranean University School of Computing and Technology Information Technology Lecture2 Functions

Laboratory #13: Trigger

OO Shell for Authoring (OOSHA) User Guide

Chapter 2 Basic Operations

Arius 3.0. Release Notes and Installation Instructions. Milliman, Inc Peachtree Road, NE Suite 1900 Atlanta, GA USA

Data Structure Interview Questions

OPERATING MANUAL. Exceed GERMANY. Electronic Postage Computing Scale CONTENTS

Student Handbook for E*Value

Enhancements to reference request templates

Lab 4. Name: Checked: Objectives:

CLIC ADMIN USER S GUIDE

PROJECT 2: Client-side Web Project

Backup your Data files before you begin your cleanup! Delete General Ledger Account History. Page 1

Transcription:

Ascii Art Capstne prject in C CSSE 120 Intrductin t Sftware Develpment (Rbtics) Spring 2010-2011 Hw t begin the Ascii Art prject Page 1 Prceed as fllws, in the rder listed. 1. If yu have nt dne s already, learn the prject specificatin what yur prject is required t d. See the AsciiArtSpecificatin dcument fr that infrmatin we discussed it in class. In a nutshell, yur prject will: Read ASCII artwrk frm a file that stres the artwrk in a simple cmpressed frm. Display the artwrk in the uncmpressed frm in which it is intended t be viewed. D sme simple manipulatins f the artwrk. It will interact with the user by repeatedly displaying (n the cnsle) a numbered menu f chices. The user enters the number fr her chice. Then the prgram des whatever is required fr that chice. This cntinues until the user selects the QUIT chice. 2. The cde that we develped in class tday is in yur individual repsitry in a prject called AsciiArtAgain Nte: AsciiArtAgain and NOT AsciiArt. Please d all yur wrk in this new prject and discard the ld ne. (If yu have cde in the riginal AsciiArt prject that yu want t keep, just cpy it int the parallel file in AsciiArtAgain.) The cde in AsciiArtAgain is similar t the cde that we develped in class, except in tw majr ways: main (and functins that main calls) is nw in a file main.c Thus, the AsciiArt.h and AsciiArt.c files cntain nly structure infrmatin and helper functins, akin t the ther.h and.c file pairs. The character field f an ArtTriple is nw just a single character, nt an array f characters. We put each structure definitin (ArtTriple, ListOfArtTriples, AsciiArt) int its wn file pair because: Each filename is the structure name with.h appended t it, s the structure definitins are easy t find. We teach sftware develpment techniques that scale up. Fr large prjects (hundreds r thusands f structures and ther such things), separating functinality int separate files is critical fr keeping intellectual cntrl f the prject. Separating.h and.c files allws the cmpiler t run faster in large prjects (it des nt have t recmpile cde in files that have nt changed). This rganizatin is standard practice in sftware develpment in C.

3. Read the cde, in the fllwing rder: ArtTriple.h This defines an ArtTriple: ArtTriple.c A rw and clumn and the character t be printed at that rw and clumn. ListOfArtTriples.h This defines a ListOfArtTriples: An array that cntains the ArtTriple s that define the artwrk in its cmpressed frm. The length (size) f that array, that is, hw many ArtTriple s it currently hlds (initially zer). ListOfArtTriples.c Page 2 AsciiArt.h This defines an AsciiArt: the cllectin f infrmatin that the prgram needs t perate n a single piece f ASCII artwrk. Fr example, the name f the file that cntains the artwrk in its cmpressed frm, the number f rws and clumns in the artwrk, and the rw/clumn/character triples that specify the nn-space characters t be printed. AsciiArt.c main.c The main functin and the functins that it calls, etc. As yu read, make sure that yu understand: Everything stred in each f the 3 structure types. The make and print helper functins fr each structure type what they d, why they d it, and hw they d it. What main is ding, and why. Send questins t csse120-staff@rse-hulman.edu. If yu run the prgram, it is currently in an infinite lp yu will fix that next. 4. Prceed accrding t this iterative enhancement plan, in which yu implement, test and debug each stage befre prceeding t the next stage. Stage 1: Implement the structures and their helper functins, the main lp in main, and the functin that shws the menu. [This is what we develped tgether in class and what yu were given in the AsciiArtAgain prject. S this stage is dne!] Except as nted, all yur wrk after Stage 1 will be in main.c. Stage 2: Currently, the prgram is in an infinite lp. Augment dealwithmenuonce s that it temprarily des ONLY this: It sets the quittingtime field f the AsciiArt structure that it is given t TRUE. (But it cntinues t return the art bject, as it des nw.) After yu implement this, the prgram shuld print the menu ONCE and quit.

Page 3 Stage 3: Augment dealwithmenuonce s that it des the fllwing part f its specificatin: It prmpts fr and inputs the number f the chice frm the menu that the user chses. Temprarily, it als prints that number, s that yu can test this stage. (Remve the print when this stage is wrking crrectly.) Stage 4: AFTER reading ALL the instructins fr this stage, augment dealwithmenuonce s that each user chice (1, 2, 81, 99) calls a sensibly-named functin t (eventually, nt yet!) deal with that chice. See, fr example, the enterfilename functin that we already supplied fr chice 1. First READ and NOTE that: Yu will mve the quittingtime cde yu previusly wrte t the case that handles the QUIT chice (99). All ther chices shuld implement stubs fr functins that (at this stage) simply print smething like Functin enterfilename is nt yet implemented. Exceptin: Yu already have (and shuld directly call) a functin printasciiart that handles the DEBUG (81) chice. Yu shuld (and ften must) prvide a prttype fr each f yur functins see the prttypes near the tp f main.c fr examples. If the user makes an invalid chice, like 9, simply print a shrt errr message like Invalid input. Try again. IMPORTANT: Yu d NOT need t d any input validatin anywhere in this prject except as explicitly specified. Fr example, yu can cunt n the user nt entering blast! (r any ther nn-numeric input) as the number she chses frm the menu. Test that ALL the chices wrk as intended s far (i.e., the lp cntinues until 99 which exits the prgram, 81 prints the default AsciiArt bject, and the ther chices print an apprpriate nt yet implemented message.) IMPORTANT TECHNICAL NOTE: Yu are very likely t encunter an errr message like:... ld.exe: cannt pen utput file AsciiArtAgain_Slutin.exe:... This almst certainly means that yur prgram is already running (prbably waiting fr input). Kill all yur running instances (get help as needed) and all shuld be OK. Stage 5 begins n the next page.

Page 4 Stage 5: [Read ALL f this LONG descriptin f Stage 5 befre implementing any f it. The cde yu write here is nt terribly lng (mine is under 40 lines f cde), but subtle yu must maintain intellectual cntrl f it.] In this stage, make Chice 3 frm the menu wrk crrectly, s that the user can enter ASCII art herself. In particular, if the user selects Chice 3, the prgram shuld: Prmpt fr and input frm the user the number f rws and clumns in the ASCII art being entered. Repeatedly prmpt fr and input frm the user: A rw number A clumn number A character t be printed at that rw and clumn Stp when the user enters a negative number fr either the rw r the clumn (and dn t include the entry with a negative rw r clumn in the data, f curse). The rw and clumn numbers shuld be zer-based. Fr example, if the number f rws is 5, then the rw number can be 0, 1, 2, 3, r 4). Yu are NOT required t d any input validatin here. See the Sample Run in the AsciiArtSpecificatin dcument fr an example f the user interactin that shuld run when the user chses Chice 3 frm the menu. Stre the infrmatin that the user inputs (per the preceding bullet) in an bject that ther functins can use. T this end, recall that yur functin that implements Chice 3 shuld be called frm the dealwithmenuonce functin. The dealwithmenuonce functin takes (as its sle parameter) an AsciiArt bject that is intended t hld all the infrmatin abut the current ASCII artwrk. Thus, yu need t: Send that AsciiArt bject t yur functin that implements Chice 3 (as its sle argument). Stre the infrmatin btained frm the user (number f rws, number f clumns, and a bunch f rw/clumn/character triples) in the apprpriate place f the AsciiArt bject sent t yur functin. Return that AsciiArt bject frm yur functin, putting it back int the same variable that was sent t yur functin, using a statement like: art = enteryurown(art) if yur functin that implements Chice 3 is called enteryurown. This is an imprtant statement; be sure yu understand exactly why it is necessary (why can t the art argument just be mutated?) and hw it achieves its gal (updating the art variable t include the infrmatin that the user enters when executing enteryurown in respnse t the user chsing Chice 3. With regard t string the infrmatin in the AsciiArt bject: The ArtTriple and ListOfArtTriples structure definitins are cmplete yu must use (call) them but shuld nt mdify them.

Page 5 On the ther hand, yu must mdify the AsciiArt structure definitin as yu cntinue t implement this prject. In particular, here yu must add fields t the AsciiArt structure definitin t hld the number f rws and number f clumns f the ASCII artwrk that Chice 3 inputs. Reset the length f the array in ListOfArtTriples t zer, since the user is nw entering a new piece f ASCII artwrk (ther menu chices let the user Other than the number f rws and number f clumns, the three structures have been set up t be exactly what yu need. Use them wisely, which includes using their makexxx helper functins. Understanding hw t stre and access infrmatin in structure instances and arrays is a critical learning bjective f this prject, s be SURE that yu COMPLETELY understand what yu are ding here and why. Dn t hesitate t ask yur instructr questins abut this (r any part f this prject). IMPORTANT TECHNICAL NOTES: Thrughut this prgram, use scanf and fscanf t d input, and d NOT use their %c frmatting cde t input a character. Instead, input a string when yu want just a character and extract and stre the first character f the string. See the discussin abut strings (Thursday in class) fr details abut hw t d this and why it is unwise t d therwise in this prgram. Use the existing (invaluable, and wrking!) printasciiart functin as yu are debugging yur cde. Yu ll need t add printf s t the existing cde that implements printasciiart, fr printing the fields that yu added t the AsciiArt structure. The symbl fr the lgical peratr OR in C is the vertical bar character (n the upper-right f mst keybards). It is quite OK, indeed recmmended, that yu add and use additinal helper functins f yur wn as yu d this prject. In my implementatin, Structure assignment, as in the third statement belw: ArtTriple a, b; a.rw =... b = a; makes a cpy f the data. (Details in class Thursday/Friday abut why this is imprtant.) Pausing and seeing the pp-up infrmatin when yu type the dt after a structure bject (as in the abve example) makes dealing with the structures much easier than it wuld be therwise.

Page 6 Stage 6: Make Chice 4 in the menu wrk crrectly. That is, implement the functin that displays the current ASCII art in its uncmpressed frm (the frm in which it is intended t be viewed). Recall that the current ASCII art is stred in the AsciiArt bject in the dealwithmenuonce functin. Thus, that bject shuld be sent t and returned frm yur functin that deals with printing the ASCII art. Yu will need a tw-dimensinal matrix f characters fr this, with the number f rws and clumns the same as yur AsciiArt bject indicates. (If the number f rws r clumns are negative, that means that there is nthing t print.) Yu: Declare the matrix (hence allcating strage fr it), per the number f rws and clumns specified in yur AsciiArt bject. Lp thrugh the matrix t make it cntain all spaces (blanks). Lp thrugh the list f ArtTriple s in yur AsciiArt bject. Fr each triple, put its character at the specified rw and clumn in the matrix. Lp thrugh the matrix, rw by rw, and within each rw, clumn by clumn, printing its characters. If yu prefer, yu can stre the tw-dimensinal matrix in the AsciiArt bject. That uses mre strage but runs a bit faster since yu dn t have t relad the characters in the ArtTriple s when yu print the matrix a secnd (r third ) time. A classic time-space tradeff. Either way is fine (and neither is a lt harder than the ther) it s yur chice. Stage 7: Make Chice 2 in the menu wrk crrectly. That is, implement the functin that reads the cmpressed-versin data frm a file instead f frm a user. This is quite similar t Stage 6. Yu can test using the plane-crds.txt file that I placed in yur AsciiArtAgain prject. Stage 8: Make Chice 1 in the menu wrk crrectly. That is, allw the user t enter than name f the file cntaining the ASCII art. Stage 9: Make Chice 7 in the menu wrk crrectly. That is, implement the functin that writes the ASCII artwrk t a file, in its uncmpressed (matrix) frm. [Mre n this Thursday.] Mre t cme, but if yu get all the abve dne, yu are in great shape.