I need to create a class that represents one crayon of a particular color and height(length). Then, I need to design an applet that lets me draw a box of different colored crayons. This is what I have so far: **CLASS:** import java.awt.*; public class Crayon { private final int BOTTOM = 150; private final int WIDTH = 25; private Color color; private int length, location; //---------------------------------------------------------------------------------------------- // Crayon's characteristics. //---------------------------------------------------------------------------------------------- public Crayon (Color color, int length, int position) { color = color; length = length; location = position; } //---------------------------------------------------------------------------------------------- // Draws crayon. //---------------------------------------------------------------------------------------------- public void draw (Graphics page) …

Member Avatar
Member Avatar
+0 forum 5

I want to create a game that computer guesses the number that i think between 0-500 but i am a beginner and i do not know what to do could you help me please ?

Member Avatar
Member Avatar
+0 forum 1

#include<iostream.h> #include<conio.h> class game { int a,b,c; public: void g() { cout<<"Enter value of a<<endl; cin>>a>>b; if(a<b) { cout<<a,<<endl; c++; } } }; void main() { game g1; g1.g(); getch(); }

Member Avatar
Member Avatar
+0 forum 2

Guys, Im wondering, If I have another class with a jpanel in it... and I add this to the jPanel, this should work correct? jpanel.add(new DoughOverviewList()); jpanel.repaint(); for some reason its not showing in my jpanel, /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package doughtracker; import java.awt.Color; import java.awt.Font; import javax.swing.BorderFactory; import javax.swing.DefaultListModel; import javax.swing.JList; import javax.swing.JScrollPane; import javax.swing.ListSelectionModel; import javax.swing.border.Border; import javax.swing.event.ListSelectionEvent; /** * * @author Acer */ public class DoughOverviewList extends JList { …

Member Avatar
Member Avatar
+0 forum 4

Hey guys, I have a little bit confused on below code and output **Main ** public class Main { public static void main(String[] args) { ClassA classA = new ClassA(); System.out.println("====== Before ====="); classA.checking(); System.out.println("===== After ====="); classA.checking(); } } ** Class A** public class ClassA { boolean b = true; public String checking() { System.out.println("B value is " + b); if (b = true) { System.out.println("B is true"); b = false; } else { System.out.println("B is false"); } return null; } } ** Output** ====== Before ===== B value is true B is true ===== After ===== B value …

Member Avatar
Member Avatar
+0 forum 4

I am very new at programming in Java. Could somebody help me out with programming a Tic Tac Toe game? I would love to have to have the code for a game that can be played against the CPU. The assignment is to write the tic tac toe game using arrays. Thanks in advance.

Member Avatar
Member Avatar
+0 forum 26

Hello, all. I am trying to calculate entropy, and I cannot get the calculations correct, or match the results with the assigned if-statements. I get a number that differentiates a bit from the answer that I want. So far, this is my code: #include <iostream> using namespace std; float Entropy(float z, float z1, float e1, float z0, float e0){ float e; e= e0 + (e1-e0)*((z-z0)/(z1-z0)); return e; } int main() { float z,e,z1,e1,z0,e0; cout << "Enter temp between 150 - 500: "; cin >> z; if(z==150){ e=7.2810; } else if(z==200){ e=7.5081; } else if(z==250){ e=7.7710; } else if(z==300){ e=7.8941; } …

Member Avatar
Member Avatar
+0 forum 4

I failed this coding challenge because my solution "does not scale for new divisors and iterations" I think it is actually a design (pattern) question, and would very much appreciate if anyone can describe a good high level solution (eg class relationships). Problem: Write a program that will iterate though a sequence of integers starting from 0 up to and including a number that can be passed in and the program will: - output the number and “FOO” only when the integer is divisible by 3 - output the number and “BAR” only when the integer is divisible by 5 …

Member Avatar
Member Avatar
+1 forum 23

![new1.PNG](/attachments/small/4/439e046d2f82534dc014d4649dea2f82.PNG "align-right") ![New.PNG](/attachments/small/4/df936d9cb59970cb9d9624ec2372f01f.PNG "align-right") ![new2.PNG](/attachments/small/4/e4dd164233946b7d726c703c6f7d470f.PNG "align-right") ![new3.PNG](/attachments/small/4/d479a91081ef39aa870d6eb0a3ca5006.PNG "align-right") Good Day, I would like some assistance, I have 12 checkboxes that when you click the value get stored into the database, then unchecked it get removed. Then now I needed a Checkbox/Uncheck All checkbox that when clicked the values get store, then unclick get removed. <b> <span> Check/Uncheck All </span> <input type="checkbox" id="checkall" /> </b>    <script type="text/javascript"> function Select(status) { $("#checkboxes input").each(function () { // Set the checked status of each to match the // checked status of the check all checkbox: $(this).prop("checked", status); }); } $(document).ready(function () { //Set …

Member Avatar
Member Avatar
+0 forum 6

Hi, I am testing a Tcp client C# windows form application I am able to send data to Tcp server Software(Hercules 3.2.8) But when i sent data from Tcp server to windows form then i am getting the following error: System.InvalidOperationException: Cross-Thread operation not valid: Control 'MessageList' accessed from a thread other than the threa it was control on. at System.Windows.Forms.ListBox.ObjectCollection.Add(Object item) at WindowsFormsAppication1.Form1.MessageCallBack(IAsyncResult ar) in From1.cs:line 55 Line 44 is at Messagelist.items.Add(response); public partial class Form1 : Form { Socket sck; EndPoint remoteEp; byte[] buffer; IPAddress ip = IPAddress.Parse("192.168.42.143"); int port = 8061; public Form1() { InitializeComponent(); } private …

Member Avatar
Member Avatar
+0 forum 1

Hi guys , is me again ! I get stucked on this question Write a program that read an integer and display its smallest prime factors in ascending order. For example, if the input is 60, the output should be 2,3,5... I came out with below code, but I get 2 2 3 5.How to have only one 2 ? package chapter4; import java.util.Scanner; public class Exercise4_16 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter an integer: "); Exercise4_16 exe = new Exercise4_16(); int value = input.nextInt(); exe.primeFactors(value); } public void primeFactors(int value) { while …

Member Avatar
Member Avatar
+0 forum 2

I need a function that will create and store usernames and passwords for different students. Their programme should ask the user for their name and age and a username should be created, consisted of their name and age eg. Jack16. They then can make up their own password which then will be stored in an external file using pickle maybe. The programme should then be able to check if the username and password is valid from the external list in a log in section. If they are valid they should be allowed in. I'm sort of stuck on this and …

Member Avatar
Member Avatar
+0 forum 3

Shows how to create a basic slide show with the Python Tkinter GUI toolkit.

Member Avatar
Member Avatar
+4 forum 19

Hi all. Been fiddling with an idea about combining setters and getters in PHP. I really don't like magic methods (`__get` and `__set`) as they're not very flexible (IMO), but equally bore myself to distraction with set/get methods. Anyhow, having used jQuery for some time, I really liked the non-verbose methods of setting and getting in the client code: var p = myDiv.html(); //getting myDiv.html("Hi all"); //setting So I came up with this as an example: public function producers( $producers = null ) { if(func_num_args() > 0){ $this->_producers = $producers; return $this; }else{ return $this->_producers; } } It uses the …

Member Avatar
Member Avatar
+1 forum 7

class space { public static void main(String args[]) { int i; for(i=0;i<5;i++) { System.out.print("*"); System.out.print("_"); } } for(i=0;i<5;i++) { System.out.println("*"); } }

Member Avatar
Member Avatar
+0 forum 3

So I have the following code contained within a class labeled book. public void setPublication(int bookVersion, String bookISBN, double bookPrice) { bookVersion = pub.setVersion(bookVersion); bookISBN = pub.setISBN(bookISBN); bookPrice = pub.setPrice(bookPrice); It refers to the following class, called publication. //Getter method to get the book ISBN public String getISBN(String bookISBN){ return ISBN; } //Getter method to get the book Version public int getVersion(int bookVersion){ return version; } //Getter method to get the book Price public double getPrice(double bookPrice){ return price; } //Setter method to set the book ISBN public void setISBN(String bookISBN){ ISBN = bookISBN; } //Setter method to set the …

Member Avatar
Member Avatar
+0 forum 2

This class gives a specified Tkinter widget a tooltip that appears as the mouse is above the widget. You can improve the code by putting in a time delay.

Member Avatar
Member Avatar
+7 forum 4

Hello, I was testing a class in a GUI, and that error message showed up. Please help. Code: [CODE]from Tkinter import * class Application(Frame): def __init__(self, master): super(Application, self).__init__(master) self.grid self.create_widgets() def create_widgest(self): self.bttn1 = Button(self, text = "I do nothing!") self.bttn1.grid() self.bttn2 = Button(self, text = "Me too.") self.bttn2.grid() self.bttn3 = Button(self, text = "Same here..") self.bttn3.grid() root = Tk() root.title("Lazy buttons") root.geometry("200x100") app = Application(root) root.mainloop[/CODE]

Member Avatar
Member Avatar
+0 forum 11

Hello everybody! Today i am writing a program to connect usées without database, with only one function: `createaccount(username,password)` That you must write on the beginning if the program. But i don't know how to finish it, with the "connect" function : class User(): def init(self, inputusername="a", inputpassword="b"): self.username = str(inputusername) self.password = str(inputpassword) def createaccount(user,pw): user = User(user,pw) def connect(userinput,pwinput): what? def loadaccounts(): createaccount("user1","mypw") createaccount("testuser","testpassword") def askuser(): while True: user = droid.dialogGetInput("User","Entrez votre nom d'utilisateur").result pw = droid.dialogGetPassword("Password","Entrez votre mot de passe").result if connect(user,pw) == True: print("ok") break else: break I am french, and so my program is. Don't Give …

Member Avatar
+0 forum 0

Hello! I am looking for some help, and have provided the code. I'm just trying to do some simple stuff. I'm trying to create a simple game without using classes (but using lists). What I'm trying to do is create collision detection among list objects ("bullets" and "baddies"), as you'll be able to see in the code. I'm also trying to fire 10 bullets at once from an "ammoCrate". My problem is that I have to stay on the "ammoCrate" in order for the bullets to do their thing, otherwise they stop in place and disappear, but continue if the …

Member Avatar
Member Avatar
+0 forum 2

I'm attempting to write a code in which the user can add as many of a certain object as needed, and blit it on to a pygame window. Essentially a game engine of sorts. I need to make it so that they can add as many of these objects as they need, so that they can create a game world. The only problem I'm encountering is that I cannot create enough names for all of this by hard-coding it, and even then it would not be enough. So is there a way for me to make it so that they …

Member Avatar
Member Avatar
+0 forum 1

Does anybody can figure out the difference between RTOS and Android?

Member Avatar
Member Avatar
+0 forum 2

When working with TCP client sockets I often find myself frustrated with the lack of event-driven support. I usually end up writing a whole bunch of code to determine disconnects, reconnecting, etc and I figuired it's time to just write my own class for this stuff. I figuired I'd share it with all of you. The implementation is quite simple, I'll provide an example below. I have XML commented all the public properties and methods, the rest is up to you to figuire out if you want to make any changes! public partial class Form1 : Form { EventDrivenTCPClient client; …

Member Avatar
Member Avatar
+5 forum 16

`1ph ## and I need you guys to explait it into detailt ## `

Member Avatar
Member Avatar
-5 forum 2

how to update Jtable by editing its cell with netbean. someone help please

Member Avatar
Member Avatar
+0 forum 1

I am trying to sort the scores in ascending order but I do not have any idea to do sorting in class. Any help will be appreciatd.

Member Avatar
Member Avatar
+0 forum 2

Hello guys, am making a desktop application using javafx and after making the exe installer with inno and wix. the problem is after installing the program everithing is working properly but when you go to source file all my classes are there intact so it can be changed easyly. HOW CAN I HIDE them or encrypt it so even if you through you can't see the really source codes? any idea please?

Member Avatar
Member Avatar
+0 forum 1

Below is my code: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <iostream> using namespace std; ///////////////////////////////////////////////////////////////////////// /* // struct Edge // Represent one edge in the graph. Fields contain // two vertex numbers and a weight. */ struct Edge { int vertex_1, vertex_2, weight; }; //////////////////////////////////////////////////////////////////////// /* // struct Graph // Represents a weighted graph. Fields contain the # of vertices, // edges,an array of edges, along with it's physical size. */ struct Graph { // V-> Number of vertices, E-> Number of edges int V, E; // graph is represented as an array of edges. Since the graph is …

Member Avatar
Member Avatar
+0 forum 6

I work in windows form 2015 when i need to read qr code i connect scanner to computer as USB then open my windows form and put cursor in specific text box as textbox4 and it read success so that How to recieve data reading from scanner to textbox4 only and split data if textbox 4 is hidden ? private void textBox4_KeyDown(object sender, KeyEventArgs e) { string[] lines = textBox4.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); if (lines.Length > 4) { textBox1.Text = lines[1].Substring(lines[1].IndexOf(":") + 1); textBox2.Text = lines[2].Substring(lines[2].IndexOf(":") + 1); textBox3.Text = lines[3].Substring(lines[3].IndexOf(":") + 1); textBox5.Text = lines[4].Substring(lines[4].IndexOf(":") + 1); …

Member Avatar
Member Avatar
+0 forum 1

My application must let a nurse enter information for a number of patients about the patients' number of repetitions for various otherwise ordinary activities. The nurse gets a book in the format to enter the information. Month Date Day Activity Repetitions January 1 Monday brushed_teeth 9 January 1 Monday combed_hair 5 January 1 Monday stepped_up_bottom_step 20 January 1 Monday cleaned_basin 40 January 2 Tuesday brushed_teeth 10 I have no luck getting information stored and looped correctly. #include <iostream> #include <string> using namespace std; struct Patient { char f_name[20]; char l_name[20]; int pat_id; char month[12]; int date; char Day[15]; char activity[50]; …

Member Avatar
Member Avatar
+1 forum 5

The End.