Off Topic > Off Topic

Programming Megathread

Pages: << < (109/241) > >>

Foxscotch:

I've been working on something for a while, it's a simple little websocket chat server and client, and it's also what I was looking at requirejs for, previously
both parts are written in javascript, with node as the server and the client is a web page (but hypothetically you could make different clients, as long as you can use websockets)
recently I've decided that I want to make a few big changes to it, that would require a lot of code changes. so I'm thinking about rewriting it in coffeescript. I'm pretty sure that would get rid of the need to use something like requirejs, while still allowing me to separate the client's source into several files (I think? I'm probably gonna have to take a closer look at how coffeescript works)
I guess I'll think about it. maybe. maybe I'll only do the client in coffeescript. I dunno, we'll see how it goes
--- Quote from: McJob on March 15, 2016, 07:12:34 PM ---I'm demoing this code to my college of people who want but cannot program, so I need to really intricately explain every little detail.

--- End quote ---
I think it makes it look a lot more confusing. like, if you've never touched a programming language, all those comments are definitely gonna make it look more complex
instead, I'd use a separate document where you explain what the code is doing
since you're using C#, I'd suggest Nocco. in this case, the comments are still in the source, but when you show it to them, they'll be to the side instead

McJob:


--- Quote from: Foxscotch on March 15, 2016, 08:00:34 PM ---if you've never touched a programming language, all those comments are definitely gonna make it look more complex

--- End quote ---
These guys have done a programming class with C# so they know what's up; it's the logic they're struggling with.


--- Quote from: Foxscotch on March 15, 2016, 08:00:34 PM ---since you're using C#, I'd suggest Nocco. in this case, the comments are still in the source, but when you show it to them, they'll be to the side instead

--- End quote ---
Oh jeeze, that thing is beautiful. Thanks for the heads-up.

Foxscotch:


--- Quote from: McJob on March 15, 2016, 10:38:00 PM ---Oh jeeze, that thing is beautiful. Thanks for the heads-up.

--- End quote ---
it's based on Docco, which could do it for you just as well, but Docco requires node.js, and you may not want to install that and npm just to use it
it seems like some of the ports made in languages other than CoffeeScript only work with their respective language, for some reason. I'm sure it has something to do with syntax highlighting. but both JavaScript and Python have very wonderful syntax highlighting libraries, so I'd go with the original Docco or Pycco if you don't use Nocco

Ravencroft·:

So I'm currently making a c++ program that determines if four side lengths inputted by the user could form a polygon, which I have done already. If they can form a polygon, the program has to determine if the sides form a rectangle or a square. The issue is that I'm not sure how to go about making an algorithm that checks if they form a rectangle(begins on the last line).

I have to do this assuming I only know how to use relational and logical operators and simple selection routines.

Here's what I have so far:

--- Code: ---//Lab 8 - Problem 3

#include<iostream>
#include<cmath>
#include<math.h>
using namespace std;

int main()
{

float a, b, c, d;

cout<<"This program will determine whether four side lengths could form a polygon. If they can, the program will also determine if the sides could form a rectangle or square.";
cout<<"side 1= ";
cin>>a;
cout<<"side 2= ";
cin>>b;
cout<<"side 3= ";
cin>>c;
cout<<"side 4= ";
cin>>d;

if (a<b+c+d&&b<a+c+d&&c<a+b+d&&d<a+b+c)
{cout<<"A polygon can be formed from these four side lengths.";
if ()

--- End code ---

Any suggestions?

$trinick:

Check if both opposing sides are the same.

if(a == c && b == d) { cout << "It's a rectangle!"; }

Otherwise, it's a polygon.

Alternately,

if(a > b+c+d || b > a+c+d || c > a+b+d || d > a+b+c) {
  cout << "A polygon cannot be formed.";
} else if(a == c && b == d) {
  cout << "It's a rectangle!";
} else {
  cout << "It's a polygon!";
}

If it has to be any 4 sides, then it gets a little more complicated:

if((a == b && c == d) ||
   (a == c && b == d) ||
   (a == d && b == c)) {
  cout << "It's a rectangle!";
}

Pages: << < (109/241) > >>

Go to full version