Programming

I can code but dont know how to make an app

Learn Programming - 8 hours 14 min ago

So I'm in my second year of University of Comp Sci. I know 3 languages enough to solve a fair share coding problems and make programs that lack a real GUI. I know since I'm asking this question, I still have a long road ahead of me in coding, but I wanna speed it up and want to make some apps even though I know I'll get there from University eventually.

My main weakness is making files interact with each other and different user info. If I wanted to make a clone of Uber for example. Getting a login, validating it, storing user info specifically and for multiple users, maps integration, and the actual features, I dont know where to start. What would be the best way to learn?

submitted by /u/bruhsmh
[link] [comments]

I seriously can't figure this out

Learn Programming - 8 hours 43 min ago

How do you paste in git bash? I know copy is control+shift+c, but control+shift+v doesn't work when I'm trying to paste. It's really annoying especially when I'm trying to clone a github repo with git bash and I have to type out the url because I still can't figure out how to copy and paste on this. All the tutorials I've read/seen seem outdated!

submitted by /u/SnowTheCone
[link] [comments]

Overwhelmed by HTML and CSS tags?

Learn Programming - 8 hours 44 min ago

This past week I've started learning how to use HTML and CSS. I was doing pretty well up until I started doing things with flex box and grids. I'm using freecodecamp.org to learn, but when it comes to doing things on my own I find myself forgetting or remembering that half the tags exist. I know it is only going to get more complicated when I dive into JS and the back-end of web development. I'm sure it is normal to be overwhelmed at the start, but is there something I should be doing to "memorize" more of the tags in languages or does it just come with experience?

submitted by /u/ItsFreakout
[link] [comments]

Folders for java projects in eclipse?

Learn Programming - 8 hours 45 min ago

I have a ton of project folders in my package explorer, so is there a way for to make regular folders to organize them? Someone told me to working sets but I don't think that is the correct way. I want to make folder for my labs, class projects, side projects etc..

submitted by /u/SneakGeek1337
[link] [comments]

Quick python scraping question using beautiful soup

Learn Programming - 8 hours 50 min ago

So I'm working on a little project to learn about python and what not, this is my first time scraping a page online so this may be an obvious answer I'm not sure.

Trying to scrape this page for some basic data, eventually trying to save the info into a JSON then use node to do a small api sort of thing online.

Page I'm scraping: https://www.pro-football-reference.com/players/K/KelcTr00.htm

So I'm trying to just collect all the rows in the first stats table. I'm using this code:

import requests from bs4 import BeautifulSoup url = 'https://www.pro-football-reference.com/players/K/KelcTr00.htm'

r = requests.get(url, timeout=10) html = r.text soup = BeautifulSoup(html, 'html.parser')

whole_season = {} rows = soup.find_all(id="stats")

I thought using id = "stats" would only grab the stats.65-80 + stats.0 (which is what I want). But for some reason its picking up both the last elements in the table, how come?

submitted by /u/DunkyourSausage
[link] [comments]

Looking to program small RF transmitter to send 2-bit signal

Learn Programming - 8 hours 54 min ago

Not too new to programming and unsure if this is the right subreddit to ask this question in

Hey guys, for my next personal project I'm looking to acquire and program and small "button," for lack of a better word, that will send a 2-4 bit signal (only need 2 for proof of concept) up to 300 ft and an accompanying receiver to process the signal. Programming hardware and radio frequencies are all completely new to me and mainly what I am looking for is: * Where to get the equipment for relatively cheap? * How do I program the transmitter and receiver? * What would I need to do to create an application that interfaces with the hardware receiver when a signal is processed?

Once again, apologies if this is in the wrong subreddit.

Also, while I am mainly looking for starting points, any tutorial links or general info dumps into the world of hardware programming and RF stuff would be greatly appreciated!

submitted by /u/kkdelux
[link] [comments]

MVC in Java: Controller and View Confusion?

Learn Programming - 8 hours 56 min ago

I keep thinking I understand MVC; however one problem persists.

If controller is responsible for the actions of JButtons, and View is responsible for showing those buttons, how am I supposed to connect them both?

I.E. Declare and set the options of the start button to be visible in the window, which is in the view class. Yet, I have the action Listener in the Controller class, and it's supposed to be the same button?

is a this and return statement needed for this?

submitted by /u/Zillakazi
[link] [comments]

Python Trivia Game Problem - AttributeError: object has no attribute

Learn Programming - 9 hours 16 min ago

I have a trivia game which runs fine for the most part except for this one error that occurs when attempting to quit the game. If the "Click to Quit" button is pushed when on the first question of the quiz (before selecting any answer), the program will freeze and the following error message will print:

Traceback (most recent call last): File "/Users/Harrison/Documents/Jeopardy/quizMain.py", line 132, in <module> main() File "/Users/Harrison/Documents/Jeopardy/quizMain.py", line 124, in main quiz_game.quiz_game_finish() File "/Users/Harrison/Documents/Jeopardy/gameboard.py", line 165, in quiz_game_finish self.EndScore = Text(Point(320, 200), ("Score:", self.Score)) AttributeError: 'gameboard' object has no attribute 'Score'

I am unsure of how to resolve this as I have very limited coding experience. Any and all help here would be very much appreciated!

Here is the code for the main program:

# this is the main program for the quiz game # import font, random, graphics # import the class programs import random from graphics import * from gameboard import gameboard def open_text_file(): # this function opens text file file = open("jepGame.txt", "r") file_list = file.readlines() return file_list def make_questions(screen, question_string): # this function splits the questions by a comma and makes it into multiple choice and question parts quest_str_list = question_string.split(",") question = quest_str_list[0] answer_a = quest_str_list[1] answer_b = quest_str_list[2] answer_c = quest_str_list[3] # the correct answer is in slot 4 correct_integer = int(quest_str_list[4]) correct_answer = quest_str_list[correct_integer] return question, answer_a, answer_b, answer_c, correct_integer, correct_answer def quiz_find_question(screen, file_list): # this function returns a list of Questions from a file list questions_list = [] length = len(file_list) random_integer = random.randint(0, length-1) for info_line in file_list: questions_list.append(info_line[:-1]) print(questions_list) question, answer_a, answer_b, answer_c, correct_integer, \ correct_answer = make_questions(screen, questions_list[random_integer]) file_list.pop(random_integer) print(len(file_list)) return question, answer_a, answer_b, answer_c, correct_integer, correct_answer, file_list def main(): # the main code for the program to run and call everything together # create the screen screen = GraphWin('Quiz Game', 640, 640) screen.setBackground('light blue') message = Text(Point(320, 60), "Quiz Game") message.setSize(36) message.draw(screen) # bring in the text file, mouse quiz_game = gameboard(screen) button_start, button_quit = quiz_game.begin_board() file_list = open_text_file() pt = screen.getMouse() # if the user clicks the quit button, clear the board, score and close the screen if button_quit.clicked(pt): quiz_game.clear_score() screen.close() # else, go into while loop if the other buttons are clicked else: while not button_start.clicked(pt) or button_quit.clicked(pt): pt = screen.getMouse() # if the start button is clicked, make it deactivated and begin the game if button_start.clicked(pt): button_start.deactivate() score = 0 ques_no = 0 # go through the 88 questions while not button_quit.clicked(pt) and ques_no < 2: question, answer_a, answer_b, answer_c, correct_integer, correct_answer, \ file_list = quiz_find_question(screen, file_list) ques_no = ques_no + 1 quiz_game.play_board(question, answer_a, answer_b, answer_c) pt = screen.getMouse() # if user clicks the quit button = break, clear the score if button_quit.clicked(pt): break response = quiz_game.check_answers(correct_integer, pt) quiz_game.clear_score() # keep the score, go to next question score = int(quiz_game.score_keep(score)) button_next = quiz_game.next() pt = screen.getMouse() # if next is clicked, clear the board if button_next.clicked(pt): quiz_game.clear_board(response) # elif the quit button is clicked = break elif button_quit.clicked(pt): break # else, continue with the game else: while (not button_quit.clicked(pt)) or (not button_next.clicked(pt)): pt = screen.getMouse() if button_next.clicked(pt): quiz_game.clear_board(response) break if button_quit.clicked(pt): screen.close() # clear the board, score and end quiz_game.clear_score() quiz_game.quiz_game_finish() while not button_quit.clicked(pt): pt = screen.getMouse() if button_quit.clicked(pt): screen.close() main()

Here is the ButtonClass:

# this is the button class program from graphics import* class Button: # A button is a labeled rectangle in a window. It is activated or deactivated with # the activate() and deactivate() methods. # The clicked(p) method returns true if the button is active and p is inside it.""" def __init__(self, win, center, width, height, label): # Creates a rectangular button, eg: qp = Button(myWin, centerPoint, width, height, 'Quit) # length and position for the button w, h = width/2.0, height/2.0 x, y = center.getX(), center.getY() self.xmax, self.xmin = x+w, x-w self.ymax, self.ymin = y+h, y-h p1 = Point(self.xmin, self.ymin) p2 = Point(self.xmax, self.ymax) # specifics for the rectangle buttons self.rect = Rectangle(p1, p2) self.rect.setFill('blue') self.rect.setOutline('blue') self.rect.draw(win) self.label = Text(center, label) self.label.setTextColor('black') self.label.draw(win) def button_right(self): # button is correct, make it green self.rect.setFill('green') def button_wrong(self): # wrong button chosen, make it red self.rect.setFill('red') def clicked(self, p): # Returns true if button active and p is inside return (self.active and self.xmin <= p.getX() <= self.xmax and self.ymin <= p.getY() <= self.ymax) def get_label(self): # Returns the label string of this button return self.label.getText() def activate(self): # Sets this button to activate self.label.setFill('yellow') self.rect.setWidth(2) self.active = True def deactivate(self): # Sets this button in inactive self.label.undraw() self.rect.undraw() self.active = False

Here is the gameboard:

# this is the quiz game board class from graphics import* from ButtonClass import Button class gameboard: def __init__(self, window): # the screen self.screen = window def begin_board(self): # set up the board with the specifics width = 125 height = 75 # the locations for the start and quit buttons center_start = Point(320, 320) center_quit = Point(500, 575) # label the buttons label_quit = "Click to Quit" label_start = "Click to Begin" # start button self.buttonStart = Button(self.screen, center_start, width, height, label_start) self.buttonStart.activate() # quit button self.buttonQuit = Button(self.screen, center_quit, width, height, label_quit) self.buttonQuit.activate() # score section self.ScoreText = Text(Point(100, 575), "Score:") self.ScoreText.setSize(20) self.ScoreText.draw(self.screen) return self.buttonStart, self.buttonQuit def play_board(self, question, answer_a, answer_b, answer_c): # the positions and sizes for the buttons and questions/answer options width = 500 height = 75 center_answer_a = Point(320, 250) center_answer_b = Point(320, 350) center_answer_c = Point(320, 450) # center_quit = Point(500, 600) # label the answers label_answer_a = answer_a label_answer_b = answer_b label_answer_c = answer_c # specifics self.Questo = Text(Point(320, 125), str(question)) self.Questo.setTextColor('blue') self.Questo.setSize(16) self.Questo.draw(self.screen) # specifics for each button self.buttonAnswerA = Button(self.screen, center_answer_a, width, height, label_answer_a) self.buttonAnswerA.activate() self.buttonAnswerB = Button(self.screen, center_answer_b, width, height, label_answer_b) self.buttonAnswerB.activate() self.buttonAnswerC = Button(self.screen, center_answer_c, width, height, label_answer_c) self.buttonAnswerC.activate() # return the following: self.buttonAnswerA, self.buttonAnswerB, self.buttonAnswerC, self.Questo def clear_board(self, response): # function to clear the game board and make the buttons deactivated self.buttonAnswerA.deactivate() self.buttonAnswerB.deactivate() self.buttonAnswerC.deactivate() self.Questo.undraw() response.undraw() def check_answers(self, right_answer, pt): # to check the answers and specify the colours self.pt = pt # while loop for the answer selected while (not self.buttonAnswerA.clicked(self.pt) or (not self.buttonAnswerB.clicked(self.pt)) or ( not self.buttonAnswerC.clicked(self.pt))): # if statement for the correct answer, display it in green if (self.buttonAnswerA.clicked(self.pt) and right_answer == 1) or ( self.buttonAnswerB.clicked(self.pt) and right_answer == 2) or ( self.buttonAnswerC.clicked(self.pt) and right_answer == 3): response = Text(Point(320, 160), str("Correct!")) response.setTextColor('green') response.setSize(20) response.draw(self.screen) self.ScoreAnswer = 1 if right_answer == 1: self.buttonAnswerA.button_right() if right_answer == 2: self.buttonAnswerB.button_right() if right_answer == 3: self.buttonAnswerC.button_right() break # if statement for the wrong button, have the two wrong choices display red elif self.buttonAnswerA.clicked(self.pt) or self.buttonAnswerB.clicked( self.pt) or self.buttonAnswerC.clicked(self.pt): response = Text(Point(320, 160), str("Wrong!")) response.setTextColor('red') response.setSize(20) response.draw(self.screen) self.ScoreAnswer = 0 if self.buttonAnswerA.clicked(self.pt): self.buttonAnswerA.button_wrong() if self.buttonAnswerB.clicked(self.pt): self.buttonAnswerB.button_wrong() if self.buttonAnswerC.clicked(self.pt): self.buttonAnswerC.button_wrong() if right_answer == 1: self.buttonAnswerB.button_wrong() self.buttonAnswerC.button_wrong() if right_answer == 2: self.buttonAnswerA.button_wrong() self.buttonAnswerC.button_wrong() if right_answer == 3: self.buttonAnswerA.button_wrong() self.buttonAnswerB.button_wrong() break else: self.pt = self.screen.getMouse() return response def score_keep(self, score): # function to keep the score of the game self.Score = score + int(self.ScoreAnswer) self.ScoreText = Text(Point(100, 575), ("Score:", self.Score)) self.ScoreText.setSize(20) self.ScoreText.draw(self.screen) return int(self.Score) def clear_score(self): # function to clear the score self.ScoreText.undraw() def next(self): # for the next button, location and size and label it center_next = Point(320, 575) width = 125 height = 75 label_next = "Next" self.buttonNext = Button(self.screen, center_next, width, height, label_next) self.buttonNext.activate() return self.buttonNext def quiz_game_finish(self): # once the user has gone through the entire game of questions: # display the score self.EndScore = Text(Point(320, 200), ("Score:", self.Score)) self.EndScore.setSize(20) self.EndScore.draw(self.screen) # display the finish statement self.EndText = Text(Point(320, 350), "You've Finished! Congrats!") self.EndText.setSize(20) self.EndText.draw(self.screen)

And lastly, here are a couple of questions from the text file:

What is the capital of Finland?, Helsinki, Santiago, Copenhagen, 1 Identify the capital of Lebanon, Jakarta, Prague, Beirut, 3

submitted by /u/MrSir333
[link] [comments]

In modern PBR pipeline, how would you handle project texture organization for general environment assets and why?

Learn Programming - 9 hours 37 min ago

Sorry if this isn't the place, but a friend of mine is learning unreal engine 4 and had this question come up on a test. Could someone explain and/or answer this?

submitted by /u/SoSoSpartan
[link] [comments]

Github/Hosting alternatives

Learn Programming - Thu, 01/17/2019 - 23:58

Hello.

I have been coding a few programs for a portfolio. But I am under the impression that anything posted to Github is shared with a community or usable in other peoples' projects.

Basically, I am just looking for a free place to host my code, applets (Mac and Windows executables), etc. Does anyone have any good suggestions? I've never done this before. I don't mind other people looking at the code, but I'd rather it not be open-source or reusable without consent.

Thanks and sorry if this is the wrong Subreddit to post in.

submitted by /u/tmogo
[link] [comments]

Arranging objects in a matrix based on rules about their neighbors

Learn Programming - Thu, 01/17/2019 - 23:48

I have a 2D grid of X by Y dimensions that I want to fill with some number of objects that fit into 4 classes (A,B,C,U). I also have a set of rules about how they can be arranged (i.e. B's can't go next to C's. C's can only be next to one U, etc.). Conceptually, how do I go about writing a program that will fill in this grid if given a certain number of objects? I think I'm hung up in part because I'm not even sure of the language to use to look up this type of problem.

For what it's worth, the end goal would be to define a "Current" version of the grid and then input some change in the # of objects (broken down by class) and have it output a filled in grid that's as similar to the "current" version as possible

submitted by /u/hopefulnuke
[link] [comments]

JAVA: how to input text from keyboard

Learn Programming - Thu, 01/17/2019 - 23:38

Question:

How do I input data from my keyboard to answer a question?

System.out.print("What is your favorite color?")

I do not know how to take input data from the keyboard because our teacher wanted us to get used to using Stack Overflow and other ways of learning. All the information I see is about Scanner/ import Scanner = new Scanner, however, I cannot get any of this to work

Thank you

submitted by /u/squicboy
[link] [comments]

Pages