462 Topics
| |
Can anyone help me with this constructor problem? In main: instantiate one date object (date1) using the default constructor just to see that the constructor works, print the month, day, and year of date1 using the getters get input from the user and use the setters to set the values … | |
import java.io.*; public class Mac extends Laptop { public static void main(String r[]) { new Mac().crunch(); } //insert code here } class Laptop { void crunch() throws IOException { } } The question is simple. Insert a code that will make the program compile. Answers are: `void crunch()` or `void … | |
int [] ia1 = {1,2,3}; int [][] ia2; Object o = ia1; ia2 = new int [3][3]; ia2[0] = (int[])o; ia2[0][0] = (int[])o; Answer is "Compilation fails in last line" Explanation: Arrays are objects, and that each array dimension is a separate type. So, for instance, ia2 is of type … | |
hey i have a question how do i get my funktion to work in the design.cs? namespace Visma_projekt { public class BlackJack { public string[] Cards = new string[51]; public void SkapaKort() { System.Console.WriteLine("Ehhhh"); } } } i want to call the funktion from this code visma.cs into the form1 … | |
Hello, Please take a look at the below code - #include<iostream> #include<ctime> // for the time() function #include<cstdlib> // for the srand() and rand() functions using namespace std; int compInput; int userInput; int die1 = 0; int die2 = 0; int Dice () { // set the seed srand(time(0)); // … | |
import java.util.*; class SampleA { } class SampleB extends SampleA{ } class SampleC extends SampleA{ } class VectorDemo { public static void main(String r[]) { Vector<SampleA> v = new Vector<SampleA>(); v.add(new SampleB()); v.add(new SampleC()); SampleC rect = v.get(2); } } The output says "Incompatible types. Found SampleA, required SampleC. SampleC … | |
My initial thoughts on the default constructor are that it was called automatically. From what I can see, it seems that this is so but a constructor called automatically doesn't initialize int or char variables for exampe, to Zero as I originally thought. It appears that they initialize the variable … | |
I need a little bit of help here. I'm new to C++ Classes. There are some errors which I do not know how to troubleshoot. The error of "Declaration terminated incorrectly" for line 6 and 7. Multiple errors of "Type name expected". Why is that? Multiple errors of "Declaration missing … | |
Hi. I am a very beginner at Java. I am taking an online course on Java and I'm stuck on an assignment. Anyone who is good with Java, can you please take a look at my code? This assignment was due yesterday but I couldn't finish it. It is very … | |
Do you need to implement a class in order for an object to access the class's functions/methods? When should you implement a class? When shouldn't you? | |
Could some one point out what's wrong with the classes of this program? #include <iostream> using namespace std; class box { private: int height; int length; int width; public: box();//constructor int surface_area(); int volume(); void set_dim(int ,int, int); }; //implementation box::box(){ int height; int width; int length;} box::int surface_area(){ int … | |
Ok, so I finally was able to convert my framework to the PSR-0 standards, but now I am getting errors in the sample application that I have not been getting before. I am not sure why, so I need a fresh pair of eyes. Any help is greatly appreciated. The … | |
Lets say I have a class A and I also have classes B and C that inherit from class A class A { virtual void foo()=0; //stuff } class B : class A { void foo(); //more specific stuff } class C : class A { void foo(); //more specific … | |
I wanted to write a simple program that uses classes but I've been running into errors. Anyone have a clue as to what is wrong with my code because I can't seem to figure it out. #include <iostream> #include <iomanip> #include <cmath> using namespace std; class cone{ private: double radius; … | |
As the title suggests, I created a base class named **member** which I want to use to get some basic information, but for some reason, I cannot seem to access those methods/values from the child class named **user_send_message** Here is the complete code that I have made so far -- … | |
some people say that multiple inheritance in java is not needed because we have interfaces or that using singular inheritance can bring the same results as using a multiple inheritance. But that is not the case. Lets take a look at the example I call “The Workbench Example” say we … | |
I am having trouble with this assignment, especially the input file and how to get the data into an array: You will design a set of classes for storing student information, along with a main program that will read student information from a file, store the data, compute final grades, … | |
currently I'm rewriting old euler solutions into classes so i can store them in a library. I wrote a program that digitizes a number so it can check to see if it a pallindrome, The base class digitize dynamically allocates memory for the size of a number and stores each … | |
Hi, I got a problem with class. I've created 3 classes: * identifiantsClass.php * connectInfosClass.php * sqlClass.php In my third class, i always have the message: "error to connect" even if my database's name is good. Please help me... * identifiantsClass.php class Identifiants{ protected $serveur=null; protected $host=null; protected $mdp=null; protected … | |
Hello to everyone! This is my first post here, I hope you can help me. I'm making a class work in python and I'm a little lost: I have to use classes to represent monomials and polynomials, and the classes should contain methods to add, substract, multiply and divide them. … | |
I would like to take string argument for class BalancedTrinary intializer, but the string type of argument is processed before it enters the init function. I guess I must override any class method which deals with those for int/long? def val(number_sequence, base): """ produce integer value of number_sequence as base … | |
hello i am creating a tictictoe game , however i cannot get the program to check if the player has won or not . and produce a you have won message #include<iostream> #include"110ct.h" using namespace std; class TICTACTOE { CursorController*crs; ColourController*cl; int xplayer ; int oplayer; colour Cs; public: void … | |
I am trying to get this class put together but I've always had trouble figuring out constructors. I don't know what to set the data fields in Customer(int customerID, int checkoutTime, int arrivalTime){} // DO NOT ADD NEW METHODS OR DATA FIELDS! class Customer { private int customerID; private int … | |
This code is supposed to respond on (w,s,a,d and q) key press..... On "w" the character ( actually the $ sign ) should move up similarly s =down , a is for left and d to move right.......... and 'q' is to quit!! Sometimes on a very few (beginning key … | |
I am having trouble with this part of my program assignment. I have created and compiled the three separate implementation files that design the three classes, they each have a default constructor, overloaded constructor, and a display function. //************************************************************************************************************ "When your program is working correctly, define an array of pointers … | |
I'm doing a lesson that is supposed to demonstrate inheritance using the song Old MacDonald; there's an animal interface, a farm class that implements each animal object.. you get the idea. I've got two problems. First, The animal has a type and a sound, for example, a chick is [code] … | |
Hi, I'm a pretty new Java student and I was just confused on a few basic concepts. What exactly is the difference between public and private classes and in which case would you use each one? also, what is a constructor, mutator, or accessor? Thank you. | |
Hi. I'm making a shooting game and since my code was getting a bit messy and big I decided to divide it into couple of classes and files. I'm confused of how to correctly split these files and classes up though. As I imagine it without really knowing if that … | |
| Yes, I know that this is homework. But I need help. This is code the teacher gave us few days ago. This is a header file. And I needed to do the following: My problem is that I didn't know how to use my vecetor in my .cpp file. How … |
Program: #include <iostream> using namespace std; class Rectangle { float len; float bre; public: Rectangle() {cout << "Rectangle constructed!" << endl; len=0; bre=0;} ~Rectangle() {cout << "Rectangle destructed!" << endl;} void setL(float L) {len=L;} void setB(float B) {bre=B;} friend float area(Rectangle rect); }; float area(Rectangle rect) { return rect.len*rect.bre; } … |
The End.