Programming Assignment #1: User Interface Module
Purpose
To implement an interpreter for our very simple BIOLA language, the very first module we want is a simple user interface module, which serves as a simple editor for editing programs written in the BIOLA language and later also serve as a front-end interface to submit the statements to a parser-evaluator module for execution. In this programming assignment, we would like to build the editor part of the module. (Later you’ll see it is easy to add additional things to make it works as a front end to the parser-evaluator module.)
Object-oriented programming
In CSCI 105 (Intro to Computer Science), we learned about the very basics of C++ programming starting from a procedure-oriented programming style. We wrote global functions, declared some global data structures shared by these functions, and primarily looked at program execution from the perspective of functions calling functions. A global function in its essence describes the procedure of doing some task according to some input arguments. In some programming languages like PASCAL, they actually use the term “procedure” to refer to the kind of global functions you write in C/C++. That is why this style is called procedure-oriented programming.
In CSCI 106 (Data Structures), we transitioned from the procedure-oriented programming style in csci105 to object-oriented programming using objects and classes. We’ll continue to use object-oriented programming style in this course. In object-oriented programming, we look at program execution from the perspective of objects interacting with objects by calling their member functions. We define classes and create objects of these classes to model real-world or conceptual objects. Data are stored as data members of the objects and the behavior of objects are specified by the member functions of their classes.
About the Interface class
To provide the functionality of the user interface, we need to implement an Interface class and an object of the Interface class must be able to read, store, and process the lines of statements written in the BIOLA language. The Interface class should implement member functions that can allow the user (as the sample interpreter in this zip file does) to
(1) read in a program as a bunch of lines of statements from a file specified by the user,
(2) display these lines of statements,
(3) append new lines of statements to the end repeatedly until a single period is entered to stop the insertion process,
(4) insert new lines before an existing line repeatedly until a single period is entered to stop the insertion process,
(5) delete a range of existing lines,
(6) replace the contents of an existing line with new things from user input, and
(7) save these lines of statements into a file specified by the use, and
(8) in addition, the Interface class should provide a startInterface member function to repeatedly display the main menu, read the user’s choice of options, and call other member functions to process the lines of statements stored in the vector of strings.
Using the
In this programming assignment, we need to use the C++ string class for processing strings (you’ll see the compiler directive #include <string> appears in the beginning of the source code). Each object of the Interface class has a vector of strings as its data member and stores the lines of statements in a Biola source program as a vector of strings. In other words, each line of statement in a Biola source program is stored as a string object in that vector of strings. This allows an object of Interface class to insert into or delete lines of statements from the vector very conveniently by appropriately calling the insert method and the erase method of the vector of strings.
What you should add into the skeleton framework to complete the programming assignment:
getline(cin, myString);
while ( myString.empty( ) )
getline(cin, myString);
Self-Evaluation and Peer Review
The programming assignment will be graded in a 0-6 scale based on the
following guidelines. You also need to fill out the self-evaluation
report with peer review and proper description of test cases conducted to check your program. Up
to 2 points will be deducted from your work if self-evaluation report is submitted without a peer review or proper description
of your test cases.