CIS 22B - Notes for Thursday, 12/3

Announcements and Reminders

  • Exercise 11 is due now
  • Assignment 11 is due Tuesday, and is not accepted late.  Corrections made to parallelogram & rhombus Data Description, the Kite area formula and the input file (12/2)
  • Final is Tuesday, 1:45 - 3:45 pm
  • Check your grades

Recording

UML

Unified Modeling Language

CIS29 Group Project Documentation

Review

      Operator Overloading:  Matrix Addition (Example 6-7 from CIS 27 notes)
  • This is a lab problem from the "old" CIS 27 final
Create a class, X, consisting of three data members, a char*, an int, and a long.  These data members are to be used to store a name (both first and last), an age, and a social security number.  Add any necessary functions to your class.  Write an overloaded insertion operator so that you can print a class object.  The overloaded insertion operator should display the members as:
  • The name should be left justified in a field of width 32.
  • The age should be right justified in a field of width 5 and displayed in hexadecimal with a base indicator.
  • The social security number should be left justified in field of width 12, displayed in decimal.
Instantiate a class object using your name, age (you can lie about your age), and social security number with a constructor that looks like this:

X object(“Joe Bentley”,25,123456789);

Use your insertion operator to write the X class object into an output file.
Turn in your program code and the output file.
main() should have only 4 lines, like this:

int main()
{
  X object(“Joe Bentley”,25,123456789);    // your name, age, ssn
  ?
  ?
  return 0;
}


Practice Problems

  • Write a complete program that meets all of the following requirements.

Create a class called ABC with the following:

a non-static data member:  a char*  (you'll be allocating  memory dynamically for this one)

A static data member: pi, initialized to 3.14

Three constructors.  A default ctor, a copy ctor, and another one

If necessary, write a destructor.

Overload the insertion operator so that it does something appropriate.

Overload the ! operator so that it prints the static data member.

Overload the assignment operator, so that you can assign one ABC object to another.

 

Write a main() that demonstrates at least one call to every function in the ABC class.

  •    Write a program that reads the “file.in” file, extracts columns 10-14 and writes the number into a file, “file.out” as shown.  The number is to be written 2 times into the file in columns of width 15 each.  The first column should be left justified, the second right justified.  The    second column should display the number divided by 100.0 in scientific notation.
“file.in”
abcdefghi123456789012345678901234567890
abcdefghi23456789012345678901234567890s
abcdefghi3456789012345678901234567890gj
abcdefghi456789012345678901234567890dnf
abcdefghi56789012345678901234567890djdi
abcdefghi6789012345678901234567890rrggg
abcdefghi789012345678901234567890fggffg
abcdefghi89012345678901234567890gbbfgfg
abcdefghi9012345678901234567890fgfgfgfg
abcdefghi012345678901234567890fgfgfgfgf
abcdefghi123456789012345678901234567890

 “file.out”

12345            1.234500E+002
23456            2.345600E+002
34567            3.456700E+002
45678            4.567800E+002
56789            5.678900E+002
67890            6.789000E+002
78901            7.890100E+002
89012            8.901200E+002
90123            9.012300E+002
1234             1.234000E+001
12345            1.234500E+002


Final format

  • Final is online and timed
  • Written problems
  • Write a program
  • Write a function
  • Write a statement
  • Evaluate an expression
  • Show the output
  • Multiple choice
Directions

You should receive an email containing a pdf attachment for the final between 1:40 and 1:45.  If you do not receive your email by 1:50, contact the instructor.
Use a plain text editor to write your answers for the test
Number each problem
Watch your time.  Your test results must be returned by email at 3:45 pm.  Add the test as an attachment.
You may use any textbooks, notes, the class web pages, assignments, exercises, your computer and compiler for this test.  
You may not get any help from anyone during this test.

Make sure you use good programming practices for your code.