• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 06:51
CEST 12:51
KST 19:51
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL19] Finals Recap: Standing Tall9HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Flash Announces Hiatus From ASL50Weekly Cups (June 23-29): Reynor in world title form?12FEL Cracov 2025 (July 27) - $8000 live event16Esports World Cup 2025 - Final Player Roster16Weekly Cups (June 16-22): Clem strikes back1
StarCraft 2
General
How does the number of casters affect your enjoyment of esports? The GOAT ranking of GOAT rankings The SCII GOAT: A statistical Evaluation Statistics for vetoed/disliked maps Esports World Cup 2025 - Final Player Roster
Tourneys
https://www.facebook.com/MiracleSheetsOnline/ RSL: Revival, a new crowdfunded tournament series [GSL 2025] Code S: Season 2 - Semi Finals & Finals $5,100+ SEL Season 2 Championship (SC: Evo) FEL Cracov 2025 (July 27) - $8000 live event
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma Mutation # 477 Slow and Steady
Brood War
General
Player “Jedi” cheat on CSL Unit and Spell Similarities Help: rep cant save Flash Announces Hiatus From ASL BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[Megathread] Daily Proleagues Small VOD Thread 2.0 [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET The Casual Games of the Week Thread
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile What do you want from future RTS games? Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine Trading/Investing Thread The Games Industry And ATVI
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
2024 - 2025 Football Thread NBA General Discussion Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Blogs
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 687 users

The Big Programming Thread - Page 293

Forum Index > General Forum
Post a Reply
Prev 1 291 292 293 294 295 1031 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Craton
Profile Blog Joined December 2009
United States17246 Posts
April 29 2013 03:22 GMT
#5841
Yes it's insufficient. That's only made for a single monitor + 1 being enabled/disabled.
twitch.tv/cratonz
phar
Profile Joined August 2011
United States1080 Posts
April 29 2013 03:43 GMT
#5842
So DisplaySwitch /internal /external or /extend and all that fails as well? I don't have my third monitor to test that on hand anymore

What card do you have? I know my ATI/AMD card is weird and can't do certain things, like 2DVI+1HDMI exhibits weird behavior, but 2DVI+1DP is somehow ok.

Do you want all three to be on at the same time? If not this guy may have a solution for you: http://www.quartertothree.com/game-talk/archive/index.php/t-66282.html

And I suppose you could always try getting DisplayFusion and using their hotkeys: http://www.displayfusion.com/Features/Functions/
Who after all is today speaking about the destruction of the Armenians?
Craton
Profile Blog Joined December 2009
United States17246 Posts
Last Edited: 2013-04-29 04:04:22
April 29 2013 04:02 GMT
#5843
I've got three extended normally on the video card and a fourth that I extend as desired on my mobo. Assuming displayswitch works the same as win+p, it wouldn't work. It's already set to extended when I bring it up and I don't want to use the other options like projector only or mirror.

I've been trying to use an AHK script from 2007, but it doesn't work (probably a 32-bit vs 64-bit issue).
twitch.tv/cratonz
phar
Profile Joined August 2011
United States1080 Posts
April 29 2013 04:47 GMT
#5844
If you can get it to work via rightclick -> screen resolution, maybe play around with autohotkey? That'd be a seriously ugly hack of a solution though.
Who after all is today speaking about the destruction of the Armenians?
Craton
Profile Blog Joined December 2009
United States17246 Posts
April 29 2013 04:49 GMT
#5845
Yes it works done manually. I have been working with AHK, but I might just switch to IronAHK the next time I approach it if there isn't a solution OOTB.
twitch.tv/cratonz
adwodon
Profile Blog Joined September 2010
United Kingdom592 Posts
April 30 2013 16:00 GMT
#5846
Ok so I just got asked to see if a HTML5 app could see our capture cards and stream them, scrounged together a basic script to get a capture.

Actually pretty interesting stuff, except I don't know shit about HTML5 and for the life of me can't seem to find what I want in documentation, despite knowing that these are rudimentary questions about JS.


navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;

var constraints = {video: true};

function successCallback(localMediaStream) {
window.stream = localMediaStream; // stream available to console
video.src = window.URL.createObjectURL(localMediaStream);
var video = document.querySelector("video");
video.play();
}

function errorCallback(error){
console.log("navigator.getUserMedia error: ", error);
}

navigator.getUserMedia(constraints, successCallback, errorCallback);


There is the script I found, I took it from http://www.simpl.info/getusermedia/.

Now I need someone to tell me how to find out more about this, specifically whats going on in successCallback.

window.stream - I can only assume window is some kind of class representing the window, where can I find the documentation?

video.src - again I can only assume some kind of class, can't find documentation for the life of me.

I'm guessing the guy who wrote this now just wants to confuse me by making a new variable called video and that has a play() method.

Seriously I just want someone to tell me how I can find documentation for this, I usually work with the windows api so I'm used to just searching msdn for any information I need, don't even know where to begin with JS as there just seems to be so much crap out there. I need to start looking into how to stream this next but I feel like this would be a good opportunity for me to learn a bit of JS as I work in C and high level languages confuse me.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2013-04-30 17:46:55
April 30 2013 17:36 GMT
#5847
Hey guys, I need help with Objective C. I'm majorly new to this language.

There is an assignment for me to create a city, a delivery item and a robot. Ok, the delivery item is generated easily, but how can I do so for the city and the robot? You may see code below:

Robot.m
+ Show Spoiler +

#import "Robot.h"

@implementation Robot

@synthesize street, avenue;

- (id) init {
// allow superclass to initialise its state first
if (self = [super init]) {
// do other initialisation ...
d = N;
}
return self;
}

- (void) move {
switch (d) {
case N: if (street >0) street --; break;
case E: if (avenue<MAXSIZE-1) avenue++; break;
case S: if (street<MAXSIZE-1) street++; break;
case W: if (avenue >0) avenue --; break;
default: break;
}
}

- (enum direction) direction { return d; }

- (void) turnleft {
// enum values are,really, integers between 0 and #count-1
if (d>1) d -=2;
else if (d==1) d=7;
else if (d==0) d=6;
}

- (void) pick: (Delivery *) x {
NSLog(@"Picking an object");
backpack = x;
}

- (Delivery *) drop {
NSLog(@"Dropping an object");
Delivery * res = [[Delivery alloc] init];
[res setStreet:[backpack street]];
[res setAvenue:[backpack avenue]];
[backpack release];
return res;
}

- (void) bag { NSLog(@"%@", backpack); }

- (int) fetch: (Delivery *) x {
return 0;
}
@end


Robot.h
+ Show Spoiler +

#import <Foundation/Foundation.h>

#import "Delivery.h"

#define MAXSIZE 10

enum direction { N, NE, E, SE, S, SW, W, NW };

@interface Robot : NSObject {
int street; // latitude in the grid
int avenue; // longitude in the grid
enum direction d;
Delivery *backpack;
}

@property int street , avenue;

- (void) move;
- (enum direction) direction;
- (void) turnleft;
- (void) pick: (Delivery *) x;
- (Delivery *) drop;
- (void) bag;

// define this method during the tutorial
- (int) fetch: (Delivery *) x;

@end


Delivery.m
+ Show Spoiler +

#import "Delivery.h"

@implementation Delivery

@synthesize street, avenue;

- (void) print {
NSLog(@"test");
}

@end


Delivery.h
+ Show Spoiler +

#import <Foundation/Foundation.h>

@interface Delivery : NSObject {
int street;
int avenue;
}

@property int street, avenue;

- (void) print;

@end


City.m
+ Show Spoiler +

#import "City.h"

@implementation City

@synthesize size;

- (id) init {
// allow superclass to initialise its state first
if (self = [super init]) {
// do other initialisation ...
robot = [[Robot alloc] init];
}
return self;
}

- (Robot *) robot { return robot; }

- (void) setRobot: (Robot *) rr { robot = rr; }

- (Delivery *) delivery { return delivery; }

- (void) genNewDelivery {
delivery = [[Delivery alloc] init];
[delivery setStreet:arc4random_uniform(size)];
[delivery setAvenue:arc4random_uniform(size)];
}

- (void) deleteDelivery { [delivery release]; }

@end


City.h
+ Show Spoiler +

#import <Foundation/Foundation.h>
#import "Robot.h"
#include <stdlib.h>

@interface City : NSObject {
int size;
Robot * robot;
Delivery * delivery;
}

@property int size;

- (Robot *) robot;
- (void) setRobot: (Robot *) rr;
- (Delivery *) delivery;
- (void) genNewDelivery;
- (void) deleteDelivery;

@end


main.m
+ Show Spoiler +

#import <Foundation/Foundation.h>
#import "City.h"
#import "Delivery.h"
#import "Robot.h"

int main(int argc, const char * argv[])
{

@autoreleasepool {
City *city = [[City alloc] init];
Robot *robot = [[Robot alloc] init];
[city genNewDelivery];
[city setRobot: robot];
NSLog(@"%@", [city robot]);

}
return 0;
}


Basically, what should be changed in 'main' if it is the only file to be changed for my question?
I'm clueless whether I've created a city or not. The PDF below doesn't help me much.

PDF for requirements: http://www.mediafire.com/view/?14c9x12rx8uyxp1

*If you have time*, could you also please help with printing the grid?
delHospital
Profile Blog Joined December 2010
Poland261 Posts
April 30 2013 17:52 GMT
#5848
On May 01 2013 01:00 adwodon wrote:
+ Show Spoiler +
Ok so I just got asked to see if a HTML5 app could see our capture cards and stream them, scrounged together a basic script to get a capture.

Actually pretty interesting stuff, except I don't know shit about HTML5 and for the life of me can't seem to find what I want in documentation, despite knowing that these are rudimentary questions about JS.


navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;

var constraints = {video: true};

function successCallback(localMediaStream) {
window.stream = localMediaStream; // stream available to console
video.src = window.URL.createObjectURL(localMediaStream);
var video = document.querySelector("video");
video.play();
}

function errorCallback(error){
console.log("navigator.getUserMedia error: ", error);
}

navigator.getUserMedia(constraints, successCallback, errorCallback);


There is the script I found, I took it from http://www.simpl.info/getusermedia/.

Now I need someone to tell me how to find out more about this, specifically whats going on in successCallback.

window.stream - I can only assume window is some kind of class representing the window, where can I find the documentation?

video.src - again I can only assume some kind of class, can't find documentation for the life of me.

I'm guessing the guy who wrote this now just wants to confuse me by making a new variable called video and that has a play() method.

Seriously I just want someone to tell me how I can find documentation for this, I usually work with the windows api so I'm used to just searching msdn for any information I need, don't even know where to begin with JS as there just seems to be so much crap out there. I need to start looking into how to stream this next but I feel like this would be a good opportunity for me to learn a bit of JS as I work in C and high level languages confuse me.


MDN is probably your best bet when it comes to HTML/JS/DOM/CSS.

OOORRRR you could've googled "js docs" and found exactly that.
adwodon
Profile Blog Joined September 2010
United Kingdom592 Posts
Last Edited: 2013-04-30 19:24:12
April 30 2013 18:14 GMT
#5849
On May 01 2013 02:52 delHospital wrote:
Show nested quote +
On May 01 2013 01:00 adwodon wrote:
+ Show Spoiler +
Ok so I just got asked to see if a HTML5 app could see our capture cards and stream them, scrounged together a basic script to get a capture.

Actually pretty interesting stuff, except I don't know shit about HTML5 and for the life of me can't seem to find what I want in documentation, despite knowing that these are rudimentary questions about JS.


navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;

var constraints = {video: true};

function successCallback(localMediaStream) {
window.stream = localMediaStream; // stream available to console
video.src = window.URL.createObjectURL(localMediaStream);
var video = document.querySelector("video");
video.play();
}

function errorCallback(error){
console.log("navigator.getUserMedia error: ", error);
}

navigator.getUserMedia(constraints, successCallback, errorCallback);


There is the script I found, I took it from http://www.simpl.info/getusermedia/.

Now I need someone to tell me how to find out more about this, specifically whats going on in successCallback.

window.stream - I can only assume window is some kind of class representing the window, where can I find the documentation?

video.src - again I can only assume some kind of class, can't find documentation for the life of me.

I'm guessing the guy who wrote this now just wants to confuse me by making a new variable called video and that has a play() method.

Seriously I just want someone to tell me how I can find documentation for this, I usually work with the windows api so I'm used to just searching msdn for any information I need, don't even know where to begin with JS as there just seems to be so much crap out there. I need to start looking into how to stream this next but I feel like this would be a good opportunity for me to learn a bit of JS as I work in C and high level languages confuse me.


MDN is probably your best bet when it comes to HTML/JS/DOM/CSS.

OOORRRR you could've googled "js docs" and found exactly that.


Yea thanks for the tip, I actually did check there but window.stream doesn't appear to be on there so I have no idea beyond a best guess what that is and whilst Document.querySelector suggests that video is an element there doesn't appear to be a play() or anything to suggest I could find it elsewhere. With regards to the video, its capturing a 720p source at 240p and I want to find if the API has anything I can do about that, figured if I found the play() function I'd find out what else I can do.

So what am I missing because clearly I've jumped in a bit over my head and I'm missing something obvious which should make this all click. I'm not used to OO docs so maybe I'm just being stupid on that front but this isn't as obvious as you might think it is to someone who hasn't done it before.

EDIT:

So I found the HTMLMediaElement Interface which defines play, still no idea where the stream property for window comes from though.
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
Last Edited: 2013-04-30 18:54:40
April 30 2013 18:51 GMT
#5850
On May 01 2013 02:36 darkness wrote:
Hey guys, I need help with Objective C. I'm majorly new to this language.

There is an assignment for me to create a city, a delivery item and a robot. Ok, the delivery item is generated easily, but how can I do so for the city and the robot? You may see code below:

Robot.m
+ Show Spoiler +

#import "Robot.h"

@implementation Robot

@synthesize street, avenue;

- (id) init {
// allow superclass to initialise its state first
if (self = [super init] {
// do other initialisation ...
d = N;
}
return self;
}

- (void) move {
switch (d) {
case N: if (street >0) street --; break;
case E: if (avenue<MAXSIZE-1) avenue++; break;
case S: if (street<MAXSIZE-1) street++; break;
case W: if (avenue >0) avenue --; break;
default: break;
}
}

- (enum direction) direction { return d; }

- (void) turnleft {
// enum values are,really, integers between 0 and #count-1
if (d>1) d -=2;
else if (d==1) d=7;
else if (d==0) d=6;
}

- (void) pick: (Delivery *) x {
NSLog(@"Picking an object");
backpack = x;
}

- (Delivery *) drop {
NSLog(@"Dropping an object");
Delivery * res = [[Delivery alloc] init];
[res setStreet:[backpack street]];
[res setAvenue:[backpack avenue]];
[backpack release];
return res;
}

- (void) bag { NSLog(@"%@", backpack); }

- (int) fetch: (Delivery *) x {
return 0;
}
@end


Robot.h
+ Show Spoiler +

#import <Foundation/Foundation.h>

#import "Delivery.h"

#define MAXSIZE 10

enum direction { N, NE, E, SE, S, SW, W, NW };

@interface Robot : NSObject {
int street; // latitude in the grid
int avenue; // longitude in the grid
enum direction d;
Delivery *backpack;
}

@property int street , avenue;

- (void) move;
- (enum direction) direction;
- (void) turnleft;
- (void) pick: (Delivery *) x;
- (Delivery *) drop;
- (void) bag;

// define this method during the tutorial
- (int) fetch: (Delivery *) x;

@end


Delivery.m
+ Show Spoiler +

#import "Delivery.h"

@implementation Delivery

@synthesize street, avenue;

- (void) print {
NSLog(@"test");
}

@end


Delivery.h
+ Show Spoiler +

#import <Foundation/Foundation.h>

@interface Delivery : NSObject {
int street;
int avenue;
}

@property int street, avenue;

- (void) print;

@end


City.m
+ Show Spoiler +

#import "City.h"

@implementation City

@synthesize size;

- (id) init {
// allow superclass to initialise its state first
if (self = [super init] {
// do other initialisation ...
robot = [[Robot alloc] init];
}
return self;
}

- (Robot *) robot { return robot; }

- (void) setRobot: (Robot *) rr { robot = rr; }

- (Delivery *) delivery { return delivery; }

- (void) genNewDelivery {
delivery = [[Delivery alloc] init];
[delivery setStreet:arc4random_uniform(size)];
[delivery setAvenue:arc4random_uniform(size)];
}

- (void) deleteDelivery { [delivery release]; }

@end


City.h
+ Show Spoiler +

#import <Foundation/Foundation.h>
#import "Robot.h"
#include <stdlib.h>

@interface City : NSObject {
int size;
Robot * robot;
Delivery * delivery;
}

@property int size;

- (Robot *) robot;
- (void) setRobot: (Robot *) rr;
- (Delivery *) delivery;
- (void) genNewDelivery;
- (void) deleteDelivery;

@end


main.m
+ Show Spoiler +

#import <Foundation/Foundation.h>
#import "City.h"
#import "Delivery.h"
#import "Robot.h"

int main(int argc, const char * argv[]
{

@autoreleasepool {
City *city = [[City alloc] init];
Robot *robot = [[Robot alloc] init];
[city genNewDelivery];
[city setRobot: robot];
NSLog(@"%@", [city robot];

}
return 0;
}


Basically, what should be changed in 'main' if it is the only file to be changed for my question?
I'm clueless whether I've created a city or not. The PDF below doesn't help me much.

PDF for requirements: http://www.mediafire.com/view/?14c9x12rx8uyxp1

*If you have time*, could you also please help with printing the grid?

You've got the alloc and init on an instance of City. That looks good to me as it is. Unless I'm not understanding what you mean by "Generate"?
CatNzHat
Profile Blog Joined February 2011
United States1599 Posts
April 30 2013 18:56 GMT
#5851
On April 26 2013 23:56 billy5000 wrote:
Thanks everyone

I guess I really lack the front-end stuff to apply it, though. I've been getting away with knowing just enough to do basic stuff I learned from web framework books. Now my weakness is growing on me, especially dealing with stuff like ajax, json and jquery (even though I already know basic javascript).

Can anybody recommend me some books/online resources for someone at my stage? It's just so much easier to pick up a decent web framework and language book/resource than to start learning front-end programming that connects the two, rather than front-end by itself. Most of the time, it's either too basic or way too complicated for my level.


The JQuery documentation is a practical solution.
I find learning things from a project standpoint works best for me, I have a goal of something to build and then I learn what is necessary to accomplish that goal. Gives me a purpose, rather than attempting to aimlessly learn a whole subject, expecting a book or some other resource to guide me perfectly.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
April 30 2013 19:38 GMT
#5852
On May 01 2013 03:51 enigmaticcam wrote:
Show nested quote +
On May 01 2013 02:36 darkness wrote:
Hey guys, I need help with Objective C. I'm majorly new to this language.

There is an assignment for me to create a city, a delivery item and a robot. Ok, the delivery item is generated easily, but how can I do so for the city and the robot? You may see code below:

Robot.m
+ Show Spoiler +

#import "Robot.h"

@implementation Robot

@synthesize street, avenue;

- (id) init {
// allow superclass to initialise its state first
if (self = [super init] {
// do other initialisation ...
d = N;
}
return self;
}

- (void) move {
switch (d) {
case N: if (street >0) street --; break;
case E: if (avenue<MAXSIZE-1) avenue++; break;
case S: if (street<MAXSIZE-1) street++; break;
case W: if (avenue >0) avenue --; break;
default: break;
}
}

- (enum direction) direction { return d; }

- (void) turnleft {
// enum values are,really, integers between 0 and #count-1
if (d>1) d -=2;
else if (d==1) d=7;
else if (d==0) d=6;
}

- (void) pick: (Delivery *) x {
NSLog(@"Picking an object");
backpack = x;
}

- (Delivery *) drop {
NSLog(@"Dropping an object");
Delivery * res = [[Delivery alloc] init];
[res setStreet:[backpack street]];
[res setAvenue:[backpack avenue]];
[backpack release];
return res;
}

- (void) bag { NSLog(@"%@", backpack); }

- (int) fetch: (Delivery *) x {
return 0;
}
@end


Robot.h
+ Show Spoiler +

#import <Foundation/Foundation.h>

#import "Delivery.h"

#define MAXSIZE 10

enum direction { N, NE, E, SE, S, SW, W, NW };

@interface Robot : NSObject {
int street; // latitude in the grid
int avenue; // longitude in the grid
enum direction d;
Delivery *backpack;
}

@property int street , avenue;

- (void) move;
- (enum direction) direction;
- (void) turnleft;
- (void) pick: (Delivery *) x;
- (Delivery *) drop;
- (void) bag;

// define this method during the tutorial
- (int) fetch: (Delivery *) x;

@end


Delivery.m
+ Show Spoiler +

#import "Delivery.h"

@implementation Delivery

@synthesize street, avenue;

- (void) print {
NSLog(@"test");
}

@end


Delivery.h
+ Show Spoiler +

#import <Foundation/Foundation.h>

@interface Delivery : NSObject {
int street;
int avenue;
}

@property int street, avenue;

- (void) print;

@end


City.m
+ Show Spoiler +

#import "City.h"

@implementation City

@synthesize size;

- (id) init {
// allow superclass to initialise its state first
if (self = [super init] {
// do other initialisation ...
robot = [[Robot alloc] init];
}
return self;
}

- (Robot *) robot { return robot; }

- (void) setRobot: (Robot *) rr { robot = rr; }

- (Delivery *) delivery { return delivery; }

- (void) genNewDelivery {
delivery = [[Delivery alloc] init];
[delivery setStreet:arc4random_uniform(size)];
[delivery setAvenue:arc4random_uniform(size)];
}

- (void) deleteDelivery { [delivery release]; }

@end


City.h
+ Show Spoiler +

#import <Foundation/Foundation.h>
#import "Robot.h"
#include <stdlib.h>

@interface City : NSObject {
int size;
Robot * robot;
Delivery * delivery;
}

@property int size;

- (Robot *) robot;
- (void) setRobot: (Robot *) rr;
- (Delivery *) delivery;
- (void) genNewDelivery;
- (void) deleteDelivery;

@end


main.m
+ Show Spoiler +

#import <Foundation/Foundation.h>
#import "City.h"
#import "Delivery.h"
#import "Robot.h"

int main(int argc, const char * argv[]
{

@autoreleasepool {
City *city = [[City alloc] init];
Robot *robot = [[Robot alloc] init];
[city genNewDelivery];
[city setRobot: robot];
NSLog(@"%@", [city robot];

}
return 0;
}


Basically, what should be changed in 'main' if it is the only file to be changed for my question?
I'm clueless whether I've created a city or not. The PDF below doesn't help me much.

PDF for requirements: http://www.mediafire.com/view/?14c9x12rx8uyxp1

*If you have time*, could you also please help with printing the grid?

You've got the alloc and init on an instance of City. That looks good to me as it is. Unless I'm not understanding what you mean by "Generate"?


I guess what I'm asking is, how do I make sure the city and the robot are created and ready to use on a grid?
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
April 30 2013 20:51 GMT
#5853
On May 01 2013 04:38 darkness wrote:
Show nested quote +
On May 01 2013 03:51 enigmaticcam wrote:
On May 01 2013 02:36 darkness wrote:
Hey guys, I need help with Objective C. I'm majorly new to this language.

There is an assignment for me to create a city, a delivery item and a robot. Ok, the delivery item is generated easily, but how can I do so for the city and the robot? You may see code below:

Robot.m
+ Show Spoiler +

#import "Robot.h"

@implementation Robot

@synthesize street, avenue;

- (id) init {
// allow superclass to initialise its state first
if (self = [super init] {
// do other initialisation ...
d = N;
}
return self;
}

- (void) move {
switch (d) {
case N: if (street >0) street --; break;
case E: if (avenue<MAXSIZE-1) avenue++; break;
case S: if (street<MAXSIZE-1) street++; break;
case W: if (avenue >0) avenue --; break;
default: break;
}
}

- (enum direction) direction { return d; }

- (void) turnleft {
// enum values are,really, integers between 0 and #count-1
if (d>1) d -=2;
else if (d==1) d=7;
else if (d==0) d=6;
}

- (void) pick: (Delivery *) x {
NSLog(@"Picking an object");
backpack = x;
}

- (Delivery *) drop {
NSLog(@"Dropping an object");
Delivery * res = [[Delivery alloc] init];
[res setStreet:[backpack street]];
[res setAvenue:[backpack avenue]];
[backpack release];
return res;
}

- (void) bag { NSLog(@"%@", backpack); }

- (int) fetch: (Delivery *) x {
return 0;
}
@end


Robot.h
+ Show Spoiler +

#import <Foundation/Foundation.h>

#import "Delivery.h"

#define MAXSIZE 10

enum direction { N, NE, E, SE, S, SW, W, NW };

@interface Robot : NSObject {
int street; // latitude in the grid
int avenue; // longitude in the grid
enum direction d;
Delivery *backpack;
}

@property int street , avenue;

- (void) move;
- (enum direction) direction;
- (void) turnleft;
- (void) pick: (Delivery *) x;
- (Delivery *) drop;
- (void) bag;

// define this method during the tutorial
- (int) fetch: (Delivery *) x;

@end


Delivery.m
+ Show Spoiler +

#import "Delivery.h"

@implementation Delivery

@synthesize street, avenue;

- (void) print {
NSLog(@"test");
}

@end


Delivery.h
+ Show Spoiler +

#import <Foundation/Foundation.h>

@interface Delivery : NSObject {
int street;
int avenue;
}

@property int street, avenue;

- (void) print;

@end


City.m
+ Show Spoiler +

#import "City.h"

@implementation City

@synthesize size;

- (id) init {
// allow superclass to initialise its state first
if (self = [super init] {
// do other initialisation ...
robot = [[Robot alloc] init];
}
return self;
}

- (Robot *) robot { return robot; }

- (void) setRobot: (Robot *) rr { robot = rr; }

- (Delivery *) delivery { return delivery; }

- (void) genNewDelivery {
delivery = [[Delivery alloc] init];
[delivery setStreet:arc4random_uniform(size)];
[delivery setAvenue:arc4random_uniform(size)];
}

- (void) deleteDelivery { [delivery release]; }

@end


City.h
+ Show Spoiler +

#import <Foundation/Foundation.h>
#import "Robot.h"
#include <stdlib.h>

@interface City : NSObject {
int size;
Robot * robot;
Delivery * delivery;
}

@property int size;

- (Robot *) robot;
- (void) setRobot: (Robot *) rr;
- (Delivery *) delivery;
- (void) genNewDelivery;
- (void) deleteDelivery;

@end


main.m
+ Show Spoiler +

#import <Foundation/Foundation.h>
#import "City.h"
#import "Delivery.h"
#import "Robot.h"

int main(int argc, const char * argv[]
{

@autoreleasepool {
City *city = [[City alloc] init];
Robot *robot = [[Robot alloc] init];
[city genNewDelivery];
[city setRobot: robot];
NSLog(@"%@", [city robot];

}
return 0;
}


Basically, what should be changed in 'main' if it is the only file to be changed for my question?
I'm clueless whether I've created a city or not. The PDF below doesn't help me much.

PDF for requirements: http://www.mediafire.com/view/?14c9x12rx8uyxp1

*If you have time*, could you also please help with printing the grid?

You've got the alloc and init on an instance of City. That looks good to me as it is. Unless I'm not understanding what you mean by "Generate"?


I guess what I'm asking is, how do I make sure the city and the robot are created and ready to use on a grid?

Based on the constraints outlined in the exercise (at least my understanding of them), it looks like there really isn't a grid. It's inferred based on the size of the grid (city.size), which represents the square size of the city (e.g., 5 = 5x5). The objects that reside in the city (robot, delivery) have x and y coordinates (street, avenue) that determine the position within the grid that they exist. So if you want to know whether the city and robot are created and ready to use on a grid, you can probably get away with just a basic NSLog output on City.Robot.Street and City.Robot.Avenue. This will tell you three things: (1) City and Robot are not nil, (2) your robot exists in the city's robot variable and it is not nil, and (3) your robot in the city has x/y coordinates.

Only thing I didn't see are the random initial coordinates for the robot. It looks like they aren't set, so they'll be 0,0 everytime.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
May 01 2013 00:00 GMT
#5854
Alright, thanks. I'll have a go tomorrow once I get an access to a Mac computer. I kind of wish the PDF didn't have so vague requirements though.
Weson
Profile Blog Joined December 2010
Iceland1032 Posts
May 01 2013 05:39 GMT
#5855
Someone told me to describe Flash API. I've been searching like a maniac and cant find anything about that. Are there even a thing called Flash API?
"!@€#" - as some guy said
tec27
Profile Blog Joined June 2004
United States3696 Posts
Last Edited: 2013-05-01 05:50:44
May 01 2013 05:49 GMT
#5856
On May 01 2013 03:14 adwodon wrote:
Show nested quote +
On May 01 2013 02:52 delHospital wrote:
On May 01 2013 01:00 adwodon wrote:
+ Show Spoiler +
Ok so I just got asked to see if a HTML5 app could see our capture cards and stream them, scrounged together a basic script to get a capture.

Actually pretty interesting stuff, except I don't know shit about HTML5 and for the life of me can't seem to find what I want in documentation, despite knowing that these are rudimentary questions about JS.


navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;

var constraints = {video: true};

function successCallback(localMediaStream) {
window.stream = localMediaStream; // stream available to console
video.src = window.URL.createObjectURL(localMediaStream);
var video = document.querySelector("video");
video.play();
}

function errorCallback(error){
console.log("navigator.getUserMedia error: ", error);
}

navigator.getUserMedia(constraints, successCallback, errorCallback);


There is the script I found, I took it from http://www.simpl.info/getusermedia/.

Now I need someone to tell me how to find out more about this, specifically whats going on in successCallback.

window.stream - I can only assume window is some kind of class representing the window, where can I find the documentation?

video.src - again I can only assume some kind of class, can't find documentation for the life of me.

I'm guessing the guy who wrote this now just wants to confuse me by making a new variable called video and that has a play() method.

Seriously I just want someone to tell me how I can find documentation for this, I usually work with the windows api so I'm used to just searching msdn for any information I need, don't even know where to begin with JS as there just seems to be so much crap out there. I need to start looking into how to stream this next but I feel like this would be a good opportunity for me to learn a bit of JS as I work in C and high level languages confuse me.


MDN is probably your best bet when it comes to HTML/JS/DOM/CSS.

OOORRRR you could've googled "js docs" and found exactly that.


Yea thanks for the tip, I actually did check there but window.stream doesn't appear to be on there so I have no idea beyond a best guess what that is and whilst Document.querySelector suggests that video is an element there doesn't appear to be a play() or anything to suggest I could find it elsewhere. With regards to the video, its capturing a 720p source at 240p and I want to find if the API has anything I can do about that, figured if I found the play() function I'd find out what else I can do.

So what am I missing because clearly I've jumped in a bit over my head and I'm missing something obvious which should make this all click. I'm not used to OO docs so maybe I'm just being stupid on that front but this isn't as obvious as you might think it is to someone who hasn't done it before.

EDIT:

So I found the HTMLMediaElement Interface which defines play, still no idea where the stream property for window comes from though.

So I think your difficulty is in not understanding how JS works, not so much the API here, so I will annotate the source to explain

// this line normalizes any browser-specific implementations. since getUserMedia is a fairly recent
// addition, browsers will often start to implement the spec (or implement while testing an
// experimental spec) under a prefixed API
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;

var constraints = {video: true};

function successCallback(localMediaStream) {
// this isn't accessing a variable at all, its creating one. It's creating a global variable named
// 'stream' (likely to be used somewhere else in a script, but not by this one)
window.stream = localMediaStream; // stream available to console

// this line makes no sense, its setting a property on a variable before the variable gets set
// (or declared, however due to hoisting this will probably not even cause an error in strict
// mode, although it doesn't do what you want). You should at the very least move this line
// below the 'var video' line.
video.src = window.URL.createObjectURL(localMediaStream);

// This sets the local variable 'video' equal to the first element in the document with the
// tagname 'video' (that is, the first <video> tag)
var video = document.querySelector("video");
// This calls the #play() function on the <video> tag (and you are correct, such an
// element would implement the HTMLMediaElement)
video.play();
}

function errorCallback(error){
console.log("navigator.getUserMedia error: ", error);
}

navigator.getUserMedia(constraints, successCallback, errorCallback);


Hope that helps, but if it does not get you to a point you'd like, you may prefer this guide: http://www.html5rocks.com/en/tutorials/getusermedia/intro/
Can you jam with the console cowboys in cyberspace?
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
May 01 2013 17:44 GMT
#5857
On May 01 2013 09:00 darkness wrote:
Alright, thanks. I'll have a go tomorrow once I get an access to a Mac computer. I kind of wish the PDF didn't have so vague requirements though.

I forgot you mentioned you wanted some help with printing the grid.

There are certainly many ways to do this. I personally would go with two functions in the City class:

(1) A function that generates a 2-dimensional array of values where each value represents a point on the grid. Look at the robot and the delivery object and use their street/avenue properties to fill out the appropriate objects in the array with a "D" or "R".

(2) A function that accepts a 2-dimensional array of values and prints it out to the screen.
waxypants
Profile Blog Joined September 2009
United States479 Posts
May 01 2013 17:59 GMT
#5858
On May 01 2013 14:39 Weson wrote:
Someone told me to describe Flash API. I've been searching like a maniac and cant find anything about that. Are there even a thing called Flash API?


Is there no other context at all? I assume they are referring to Adobe Flash. I know almost nothing about programming Flash except that I seem to remember from like 10 years ago when I tried messing with the Flash developer software that you can write JS scripts for it. Googling for 2 minutes gave me this:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/index.html?filter_flashplayer=11.7

and

http://en.wikipedia.org/wiki/ActionScript_3

I haven't looked much beyond that, but it seems that is what you want.
Orome
Profile Blog Joined June 2004
Switzerland11984 Posts
May 02 2013 16:17 GMT
#5859
Hey guys, was hoping someone could help me out again real quick. I'm trying to make a vector-based heap of std:: pairs. My solution seems to be identical to the one they provided us with, but somehow it doesn't work. When I try to do something like this:


heap[1] = item(k, e);


the program crashes.

item is defined as:

typedef std::pair<int, string> item;

heap's a class variable, defined as:

std::vector<item> heap;


I appreciate any help.
On a purely personal note, I'd like to show Yellow the beauty of infinitely repeating Starcraft 2 bunkers. -Boxer
netherh
Profile Blog Joined November 2011
United Kingdom333 Posts
May 02 2013 16:23 GMT
#5860
On May 03 2013 01:17 Orome wrote:
Hey guys, was hoping someone could help me out again real quick. I'm trying to make a vector-based heap of std:: pairs. My solution seems to be identical to the one they provided us with, but somehow it doesn't work. When I try to do something like this:


heap[1] = item(k, e);


the program crashes.

item is defined as:

typedef std::pair<int, string> item;

heap's a class variable, defined as:

std::vector<item> heap;


I appreciate any help.


Does heap actually have any items in it? You're assigning to the second element in heap, but if heap doesn't have a second element, it'll just crash.

That's just a guess without more code though.
Prev 1 291 292 293 294 295 1031 Next
Please log in or register to reply.
Live Events Refresh
RSL Revival
10:00
Season 1: Playoffs Day 2
herO vs SHIN
Reynor vs Cure
Tasteless776
3DClanTV 90
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Crank 1438
Tasteless 765
Harstem 142
IndyStarCraft 134
Rex 114
StarCraft: Brood War
Calm 9717
firebathero 5922
Rain 5013
Horang2 1608
Jaedong 1511
Larva 554
Pusan 491
actioN 404
BeSt 317
Leta 280
[ Show more ]
EffOrt 162
Light 143
Mini 140
ToSsGirL 135
Rush 111
Hyun 110
PianO 78
JYJ53
JulyZerg 48
Mind 48
Killer 35
Backho 28
Sharp 24
Mong 23
NaDa 23
HiyA 18
sSak 17
Sacsri 14
zelot 12
Shinee 10
Movie 8
IntoTheRainbow 7
SilentControl 5
Bale 4
Barracks 4
Dota 2
XcaliburYe744
XaKoH 408
420jenkins279
League of Legends
JimRising 348
Counter-Strike
shoxiejesuss811
Stewie2K558
allub254
Other Games
DeMusliM412
Pyrionflax234
ArmadaUGS93
rGuardiaN53
Lowko34
Organizations
StarCraft 2
ComeBackTV 580
IntoTheiNu 37
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• Berry_CruncH255
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• iopq 3
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Stunt468
Upcoming Events
OSC
2h 9m
WardiTV European League
5h 9m
Scarlett vs Percival
Jumy vs ArT
YoungYakov vs Shameless
uThermal vs Fjant
Nicoract vs goblin
Harstem vs Gerald
FEL
5h 9m
Big Brain Bouts
5h 9m
Korean StarCraft League
16h 9m
CranKy Ducklings
23h 9m
RSL Revival
23h 9m
FEL
1d 5h
RSL Revival
1d 23h
FEL
2 days
[ Show More ]
BSL: ProLeague
2 days
Dewalt vs Bonyth
Replay Cast
3 days
Sparkling Tuna Cup
3 days
The PondCast
4 days
Replay Cast
5 days
RSL Revival
5 days
Replay Cast
6 days
RSL Revival
6 days
Liquipedia Results

Completed

Proleague 2025-06-28
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
BSL Season 20
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.