Construct that is used as template for creating new objects. Class describes the state and behavior that the objects of the class all share.
0
votes
0answers
2 views
Implementation of OOP for retrieving list of objects from database
If I have a class defined as Person that outlines the fields of person and one of people that just contains a list of the person's like so:
public class Person
{
public Person(){}
public int personID ...
1
vote
0answers
25 views
Are there any apparent issues with using this pattern?
I've been experimenting with the IIFE module pattern ever since I've learned of it. Recently, I've started combining it with classes to seek some further inheritance benefits without manually ...
2
votes
1answer
14 views
Get Ancestor Class Name that Defines CONST in PHP?
I have a class hierarchy in PHP and in some of the parent classes I have defined a constant, let's assume that constant is called TYPE for my example.
I want to be able to pass in a valid value for ...
0
votes
0answers
23 views
Could someone restructure my applet? [closed]
A couple of days ago I made a working applet where two balls bounced off of eachother and off of the walls of the rail (it was just a 2d applet). Then I was told to make a class for the ball. I ...
2
votes
2answers
73 views
Building a Red Black tree using a structure as a node
I have the following structure:
struct Keys
{
//value of word in the vector<string> words.
string word;
//index of word in the vector<string> words.
int index;
//I want to ...
3
votes
1answer
60 views
Marking class with no abstract methods as an abstract
Consider an interface:
public interface IWindowOperations
{
// Some operation methods.
}
Class definitions:
public abstract class BaseWindow<T> : IWindowOperations
{
// partially ...
-1
votes
0answers
18 views
Identifier Errors - new to programming [closed]
#ifndef __CALENDAR_H__
#define __ CALENDAR_H __
#include "Day.h"
#include <string>
using namespace std;
class Calendar
{
public:
Calendar();
~Calendar();
void SetUseLongDays(bool ...
1
vote
1answer
26 views
A better way for class management with jQuery
so I've made a carousel, which uses a function that is passed a target element, and from this element it adds next, prev, next next, and prev prev classes to its siblings (causing the rotation) - what ...
2
votes
1answer
58 views
User system using PDO
I'm making a very basic user system, and this is what I have so far:
<?php
/* The class for constructing any user's information
*/
class User {
protected $userId, $email, ...
3
votes
1answer
43 views
Review/rate my new graph class
I have written a PHP class called "graph". It is a class that performs RESTful-like commands to a MySQL database. I have posted the GitHub repo.
Here is the code as well:
config.php
<?php
...
2
votes
2answers
85 views
Kings Drinking Game review request
This Review Request evolves into this Review Request now with a custom UI and other changes.
I wrote a program to simulate the drinking card game Kings. This is my third Java Project. I didn't quite ...
4
votes
1answer
72 views
Critique of Pascal's Triangle Class
I'm working my way through The Java Programming Language, Fourth Edition - The Java Series. This is Exercise 7.3:
Write a program that calculates Pascal's triangle to a depth of 12, storing each ...
1
vote
0answers
100 views
Do I need inheritance or no?
I'm using Pygame to create a small game with few rectangle shapes. However, I want to learn more about classes, and I'm trying to use them. I'm very new to classes and inheritance, but I want to ...
1
vote
0answers
59 views
Basic structure of a simple php REST api
I've read plenty about php OOP design principles and patterns. I can work with classes and inheritance. My issue is with actually using classes for some purpose. In this case, I want to create a ...
4
votes
2answers
153 views
Random password generator
I just wrote my first Java class, and I wanted to share it with you and maybe get some quick check from more experiences coders than I am.
I want to learn OOP, Java is just the tool I thought was the ...
3
votes
1answer
104 views
Review/optimization of craps game rules and code: version 2
Thanks to all who've answered my previous question. I've taken all the advice and created a Craps class and gameplay. I just wanted to ask for more advice on how to optimize my code.
#include ...
1
vote
2answers
41 views
What is a better way to organize this Python code in a class?
I wrote a script that will eventually go onto a Raspberry Pi. It takes a picture then uploads it to Twitter every 15 minutes from 5:30-9:00pm.
It works fine as is, but I feel I need to organize ...
1
vote
1answer
23 views
Throwing error if settings / arguments are undefined is this a good breakout function?
var _ = require("underscore");
var checkSettingsUndefined = function(settings){
if(_.isEmpty(settings)){
throw new Error("settings are empty");
}
}
var Class = function(settings){
...
1
vote
2answers
149 views
Review of Dice class
I don't intend on implementing this into an application yet as I'm going to test it first. As such, it doesn't do much beyond rolling. It also overloads some "typical" operators such as == and !=.
...
0
votes
1answer
231 views
Java Fraction Class - Adding Together Two Objects [closed]
I'm currently working on a fraction class. I've successfully figured out how to create a fraction object as well as check for errors but I've blanked and cannot figure out how to add together the two ...
1
vote
2answers
73 views
In this script what can I turn into funtions and how can I go about doing it?
I have just made a simple script which spawns an alien that chases the player, but I want to move as much of the script into funtions so as to minimize the amount of code, to make it run better when ...
2
votes
3answers
206 views
Simple class exercise - min, max, and average of vector items
This program calculates the min and the max value and the average of the items of a vector. It's an exercise from a book so I can't change the header file.
Is this code proper?
sales.h
#include ...
2
votes
3answers
130 views
Simple class exercise using the “this” pointer
This is my solution for an exercise from a book. It's a simple Golf class with member variables fullname and handicap. The constructor sets the variables to the provided name and handicap using ...
1
vote
1answer
120 views
Critique my PHP Cookie class?
I wrote this class to make cookie management easier.
I know it makes use of serialize(), but I have no intention of storing very much data in the cookie, and it seemed a cleaner solution than, say, ...
4
votes
1answer
102 views
Shader class implementation
I'm trying to design a Shader class. For now, I'm just trying to get basic outline for handling uniforms. Some design goals I aimed for is to avoid passing a string to a function as this is error ...
3
votes
2answers
121 views
Is the use of Struct or Class personal preference?
I have a solution in which I instantiate a class with various types inside of it. I feel it is becoming to cumbersome to instantiate and then create variables for each of the types I want to access ...
0
votes
1answer
51 views
Why isn't it giving me a color for my apple? [closed]
This is not homework; just an exercise I'm doing on my own.
In my main:
apple j = new apple();
j.Flavor = "sweet";
j.Color = "green";
Console.ReadKey(true);
In a class:
using System;
using ...
1
vote
1answer
77 views
File Downloading, Unzipping and extracting Content - PHP script and tests
EDIT. Here is the new version after bumperbox's very helpful suggestions.
I was thinking or renaming into Downloader or something but the problem is, I see downloading is performed at lower level of ...
2
votes
0answers
73 views
Loading 'Plugins' in Ruby
I have written a plugin loader in Ruby, and I would like to know if it uses the best technique to handle classes, or if anyone has any recommendations on how to improve my code.
I have written a ...
3
votes
1answer
181 views
Improving remake of factoring/prime factorization calculator
Background info on factoring and prime factorization.
I've remade this program from my first attempt, and I'm sure it can still be improved. My questions:
These calculations should only be done ...
2
votes
1answer
64 views
Streamlining repetitive class definitions in python with a class_factory() function
I forked this repo to be more concise. The code is here. I'll paste it below since that seems to be the style. I removed the class definitions at the bottom that I didn't change -- the edit I'm ...
4
votes
2answers
94 views
I know I'm not doing these methods right
I'm having difficulty understanding the implementation of methods in classes. I'm pretty sure I'm not doing this the correct way. Can anyone show me the way it should be done.
This code works by ...
6
votes
1answer
243 views
Critique Request: PHP Request-Method Class
I'm working on a general Requestmethod class which sanitizes and recasts the input of users in an automatic fashion. I've also tried to do array-access in cookies.
My biggest question are:
Is this ...
1
vote
2answers
92 views
How can I improve the logic of my code?
I was trying to solve this problem on leetcode:
http://leetcode.com/onlinejudge#question_2
and my solution can be found here:
public class Solution {
public ListNode addTwoNumbers(ListNode l1, ...
3
votes
2answers
145 views
Trying to use classes in my python code. Not sure if being done correctly
The point of my code is to:
Read in the observed data from the a catalog of stars (whitespace separated table).
Do some unit conversions on the observed data (math stuff).
Apply an interstellar ...
1
vote
1answer
91 views
Representing database row as a class
For my current project, I have elected to represent database rows as objects.
So an individual comment can be retrieved as a class like so:
$comment = new Comment(1);
Here is the Comment class ...
9
votes
1answer
384 views
Should I put default values of attributes on the prototype to save space?
Suppose I've got a JavaScript function that I'm treating like a class - that is, I want to make many instances of it:
function Blerg() {
this._a = 5;
}
Blerg.prototype.getA = function() {
return ...
6
votes
3answers
486 views
C++ Is this class well written?
I'm a C++ beginner and made a simple class. But I'm not sure if this is well written. It's basically just a Date Class.
#include <iostream>
using namespace std;
class Date{
int d, m, y; ...
2
votes
2answers
164 views
Object-oriented design of list of primes
Is there a better way to implement this class, or does it not constitute implementation in the first place? This is one of my first few tries at OOP. Any suggestions will be much appreciated.
...
0
votes
0answers
27 views
Another php upload class
i know there are many php upload classes out there but i'm mostly comfortable with my own code.
So i made a simple one here.
I'm interested about your opinion on the approach on image files in case ...
3
votes
4answers
444 views
Text-based RPG game using classes
I am studying for a degree in "Bachelor of Engineering in Information and Communication Technologies." I am currently on vacation, just after we started learning C++ at the end of the semester. I ...
0
votes
3answers
118 views
Objective-C class for placing UI elements based on screen size
I'm always programmatically creating and laying out UI elements in multiple ViewControllers and I've wanted an easy way to get relevant Screen information (sizes/points) globally using a helper class. ...
3
votes
2answers
226 views
PHP Classes and variables
Hy all,
First of all, i'm trying to learn OOP PHP, so any advise will be great ( and sorry for the bad English ).
The later idea is to create some kind of MVC Framework CMS kind of thing, just to ...
0
votes
2answers
80 views
Extending a simple Python console program with external code. Did I handle this correctly?
I'm a hobbyist Python programmer with not much experience.
I wrote some code for a solution to a Tic Tac Toe AI problem on the internet.
Then yesterday I wrote a simple console Tic Tac Toe game for ...
2
votes
1answer
158 views
Should I use a class as a class factory in Python?
As a bit of a learning project, I decided to take the concept of proxying objects a bit further and extend it to creating proxy classes which create proxy'd objects. I originally found the idea of ...
2
votes
1answer
100 views
Is this nested class design ineffective for my Deck class?
Previous review of this project: Proper use of multiple classes and member-accessing with one header?
I'm nearly finished with my deck of cards project, and this time I made changes to hide the Card ...
1
vote
2answers
53 views
Proper use of multiple classes and member-accessing with one header?
Previous review of this project: Am I following any bad practices in my updated Card and Deck classes?
This time, I considered combining both classes into one header file so that I can reduce my use ...
3
votes
2answers
95 views
Copy object properties without using many if statements
I have two class:
InputForm.java
public class InputForm {
private String brandCode;
private String caution;
public String getBrandCode() {
return brandCode;
}
public ...
1
vote
1answer
75 views
Am I following any bad practices in my updated Card and Deck classes?
This code was first critiqued here (without the Card class): Please critique my C++ Deck class
After learning more about data structures both online and in class, I wanted to revisit my Card and Deck ...
2
votes
1answer
151 views
overloaded const and non-const class methods returning references in C++
I have a data-structure class in C++ with an accessor to some object (may be large) and I have const and non-const methods using this accessor so I need to overload it. I am looking for a critique of ...