class

How do I change a superClass attribute that's inside of a subClass?

三世轮回 提交于 2020-01-25 07:24:28
问题 When I define the __init__ of ProductionWorker , I also need to set the attributes of EmployeeClass . I entered "Bob" and "001121" as a test and it works but I need to be able to change it in my main from the input of the user. class ProductionWorker(EmployeeClass): SHIFT = {1: "day shift", 2: "night shift"} def __init__(self, shift=None, hourly_pay=None): EmployeeClass.__init__(self, "Bob", "001121") self.__shift = shift self.set_shift = shift self.__hourly_pay = hourly_pay self.set_hourly

How do I pass in a class to make an array of classes?

可紊 提交于 2020-01-25 06:47:11
问题 I want to create a class (Array) that performs different methods on arrays. What I have so far is overloaded constructors for different types of arrays (ints, strings, etc). However this class will also need to create an array of classes, so how could I pass in a class name and have my Array class create an array of that class? I could just hard code it in for the class I know I will make an array of but I want to make my Array class versatile enough to have this work with any class I make in

Call a function or method from inside its class

こ雲淡風輕ζ 提交于 2020-01-25 03:44:07
问题 I have written a database class but can't access the method from within: class database{ . . private $mgc; private $real; public function insert($table,$values,$row = null){ . . for($i = 0; $i < count($values); $i++){ $values[$i] = safe_value ($values[$i]); } . . } public function safe_value( $value ) { if( $this->real ) { if( $this->mgc ) { $value = stripslashes( $value ); } $value = mysql_real_escape_string( $value ); } else { if( !$this->mgc ) { $value = addslashes( $value ); } } return

c# get parent from chlid instance

∥☆過路亽.° 提交于 2020-01-25 03:35:06
问题 I try to get the parent Type of a instance. How can I do ? Example : public class a { public b { get; set; } } public class b { } var a = new a(); a.b = new b(); var parentType = a.b.??GetParentInstanceType()?? 回答1: You can't. You'd need to add a property to the child manually to keep track of the parent: Here is one way: public class A { public B<A> Child { get; set; } } public class B<T> { public T Parent { get; set; } } A a = new A(); a.Child = new B<A>(); a.Child.Parent = a; Type

jQuery add numbered class recursively to blocks of divs

梦想与她 提交于 2020-01-25 01:43:12
问题 I'm dinamically wrapping a fixed number of divs from an array (e.g. 4 in each group). The number of .item div's returned from the array is unknown... I need to recursively add the same class to those groups of divs wrapped toghether: <div class="wrapper"> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> </div> <div class="wrapper"> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> </div> <!--

importing value to another class

末鹿安然 提交于 2020-01-25 00:11:30
问题 btnRegister.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { String name = inputFullName.getText().toString(); String email = inputEmail.getText().toString(); String password = inputPassword.getText().toString(); if (!name.isEmpty() && !email.isEmpty() && !password.isEmpty()) { registerUser(name, email, password); } else { Toast.makeText(getApplicationContext(), "Please enter your details!", Toast.LENGTH_LONG) .show(); } return name; //<-here is the error } i

how to get the value from a textbox that is next to my text

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-25 00:05:21
问题 i have an html page where i have a table of items (one item per row) where each item is a html link that says "Add" and there is a textbox next to each link with a number in it. the text link and the textbox are in the same td inside the row of the table. how do i, using jquery, capture the value from the textbox that is to the right of the link i click on. 回答1: You could give your link a class, then do this: $("a.myClass").click(function() { alert($(this).next().val()); }); If you have a lot

I am trying to implement NFA in Python to recognize words but my code doesn't work,

拥有回忆 提交于 2020-01-24 23:57:09
问题 I am trying to implement a method that recognizes words. I have written the following code and have tried to follow my code on paper and execute it step by step with example inputs, but I can't find the reason why my code is not doing what I want him to do. Does anyone see the flaw? I can't see it and I am confused on why it doesn't work. from collections import defaultdict class NFA: def __init__(self, initial, trns, final): self.initial = initial self.final = set(final) self.trns =

One 'compressed' file of classes vs multiple class files in PHP

…衆ロ難τιáo~ 提交于 2020-01-24 22:47:47
问题 Is there any gain to combining all of the classes for a project into one massive 'compressed' file (spaces and comments removed) vs loading each class as they are required (other than all of the classes are there so you don't have to require/include them, isn't that what we have __autoload for?)? It seems to me that loading each class as needed would be a lot less strenuous on php. 回答1: Generally, in the vast majority of cases, for any non-trivial number of classes, you want some kind of

C++: Read and write classes

廉价感情. 提交于 2020-01-24 22:42:40
问题 #include <cstdlib> #include <iostream> #include <fstream> #include <string> using namespace std; class PERSON{ string name, surname; public: void set_name(string aname, string asurname){ name = aname; surname = asurname; }; void read(){ } void output(){ cout << name << " " << surname << "\n"; } void save(PERSON *x){ ofstream file("test.bin", ios::out | ios::app | ios::binary); if(!file.is_open()){ cout << "ERROR\n"; }else{ file.write((char*)x, sizeof(*x)); file.close(); } } }; /* * * * */ int