Skip to content

Instantly share code, notes, and snippets.

View zachlatta's full-sized avatar
🏴‍☠️

zach latta zachlatta

🏴‍☠️
View GitHub Profile
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
// Creates the structure Scenea
struct Scene {
// Constructor that passes the arguments to text and to next which sets scene_text to the value of text and next_scenes to the value of next
Scene(std::string text, std::vector<int> const& next) {
scene_text = text;
/* Write a program that lets a maker of chips and salsa keep track of their sales
for five different types of salsa they produce: mild, medium, sweet, hot, and
zesty. It should use two parallel five-element arrays: an array of strings that
holds the five salsa names and an array of integers that holds the number of jars
sold during the past month for each salsa type. The salsa names should be stored
using an initialization list at the time the name array is created. The program
should prompt the user to enter the number of jars sold for each type. Once this
sales data has been entered, the program should produce a report that displays
sales for each salsa type, total sales, and the names of the highest selling and
lowest selling products.
@zachlatta
zachlatta / gist:3746613
Created September 18, 2012 23:06
Assignment: Internet Service Provider
/* An Internet service provider has three different subscription packages
* for its customers.
*
* Package A: For $9.95 per month 10 hours of access access are
* provided. Additional hours are $2.00 per hour.
*
* Package B: For $13.95 per month 20 hours of access are provided.
* Additional hours are $1.00 per hours.
*
* Package C: For $19.95 per month unlimited access is provided.
@zachlatta
zachlatta / gist:3773825
Created September 24, 2012 02:06
Bar Chart
import java.util.Scanner;
public class BarChart {
public static void main(String[] args)
{
double[] store = new double[5];
Scanner userInput = new Scanner(System.in);
@zachlatta
zachlatta / gist:3829950
Created October 3, 2012 21:26
Sleep function
#include <time.h>
void sleep(unsigned int mseconds)
{
clock_t goal = mseconds + clock();
while (goal > clock());
}
@zachlatta
zachlatta / SavingsAccount.java
Created October 9, 2012 00:48
SavingsAcccount Class
public class SavingsAccount {
private double annualInterestRate, balance, accumulativeInterest, accumulativeDeposits = 0, accumulativeWithdrawals = 0;
// Constructor
public SavingsAccount(double b)
{
balance = b;
}
// Mutators
@zachlatta
zachlatta / gist:3862630
Created October 10, 2012 01:37
Reading two files and outputting data
// Opens files
BufferedReader deposits = new BufferedReader(FileReader("Deposits.txt");
BufferedReader withdraws = new BufferedReader(FileReader("Withdrawals.txt");
// Reads from files and prints to console
String depositString;
String withdrawString;
double deposit;
double withdraw;
@zachlatta
zachlatta / Character.cc
Created November 17, 2012 18:53
Character Class
#include "../Header/Character.h"
#include <iostream>
#include <fstream>
/********************
* PRIVATE METHODS *
********************/
void Character::setExperience(int experience)
{
public static void loadBooks(ArrayList<Book> books, String fileName)
{
try(Scanner scanner = new Scanner(new File(fileName)))
{
String currentLine;
String delims = ", ";
String[] tokens;
scanner.useDelimiter(", ");
This may be a bit off-topic for this channel. I have a programmer who is above me who insists on using a code generator for a project. I experimented with the generator and I have a few issues with it. My biggest issueis that it generates messy code. It doesn't take advantage of C++ conventions and it clearly Java with a few tweaks to make it compile with a C++ compiler. I'm also afraid that some of the programmers on the team with less experience won't know what the underlying code does. Any ideas on how to express this to a superior?