This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gist https://gist.github.com/mshafae/f3405bece8f6293036cbd94f2ae555c1 | |
// Filename cpsc120_simple_image.cc | |
// CompileCommand clang++ -std=c++20 -I /usr/include/GraphicsMagick -lGraphicsMagick++ cpsc120_simple_image.cc | |
// Create a simple PNG image. | |
#include <Magick++.h> | |
#include <iostream> | |
int main(int argc, char* argv[]) { | |
const int kImageWidthAndHeight{512}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gist https://gist.github.com/mshafae/978da2ef9ca32695d1ac0396c1427feb | |
// Filename cpsc120_is_even.cc | |
// CompileCommand clang++ -std=c++20 cpsc120_is_even.cc | |
// Check to see if a number is even or not | |
#include <iostream> | |
// Poor style | |
// bool IsEven(int number) { | |
// if ((number % 2) == 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gist https://gist.github.com/mshafae/0a21e4c9277838ed0c57e3e9b9ecd5a3 | |
// Filename cpsc120_common_if_mistakes.cc | |
// CompileCommand clang++ -std=c++17 cpsc120_common_if_mistakes.cc | |
// Common mistakes with if, else-if, and else | |
// -- Start -- Turns off warnings - do not do this at home | |
#pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare" | |
#pragma clang diagnostic ignored "-Wempty-body" | |
#pragma clang diagnostic ignored "-Wparentheses" | |
// -- End -- Turns off warnings - do not do this at home |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Tested on Ubuntu 24.04 LTS with tusk packages, https://github.com/mshafae/tusk | |
"""A lab configuration file. To turn off TODO linter check, set LABSOLUTION in your environment, ex. `LABSOLUTION=YES make lint`""" | |
from datetime import date | |
from os import environ | |
# | |
# -- START -- For each lab update this section -- START -- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import pickle | |
from highscore import HighScore | |
def main(): | |
# 13 23 33 100 345 | |
print('hello world') | |
score_list = [HighScore(13), HighScore(23), HighScore(33), HighScore(100), HighScore(345)] | |
print(score_list) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gist https://gist.github.com/mshafae/2a5eaf94a0f7f81f725dc8e29872c107 | |
// Filename list_with_cpp_ptr.cc | |
// CompileCommand clang++ -std=c++17 list_with_cpp_ptr.cc | |
// Doubly linked list using C++ style shared and unique pointers. | |
#include <iostream> | |
#include <memory> | |
class Printable { | |
public: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gist https://gist.github.com/mshafae/102aefa38e3b28b83ad4357201e93d3a | |
// Filename list_with_c_ptr.cc | |
// CompileCommand clang++ -std=c++17 list_with_c_ptr.cc | |
// Doubly linked list using C style pointers. | |
#include <iostream> | |
class Printable { | |
public: | |
virtual void Print(std::ostream& out) = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gist https://gist.github.com/mshafae/d6704ddbb9f360d6ccd53dc979cc4776 | |
// Filename cpsc120_words_to_vector.cc | |
// CompileCommand clang++ -std=c++17 cpsc120_words_to_vector.cc | |
// Read a file word by word and place contents into a std::vector | |
#include <fstream> | |
#include <iostream> | |
#include <string> | |
#include <vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gist https://gist.github.com/mshafae/396db34b08fb9d3b553358778d176f56 | |
// Filename cpsc120_function_pointer.cc | |
// CompileCommand clang++ -std=c++17 cpsc120_function_pointer.cc | |
// Demonstrates how to work with functions and member functions as pointers. | |
// Generally speaking, don't do this unless you need to. You will probably | |
// find that function objects and lambda expressions will get you more mileage | |
// in C++ however this knowledge is useful. | |
#include <iostream> | |
#include <string> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gist https://gist.github.com/mshafae/00875dc88635dfb640278b2259b19fb3 | |
// Filename cpsc120_virtual.cc | |
// CompileCommand clang++ -std=c++17 cpsc120_virtual.cc | |
// Demonstrates how virtual works in C++ | |
#include <iostream> | |
#include <string> | |
class Fizz { | |
public: |
NewerOlder