Overriding the equals method - having trouble guys and/or gals.  I'm having some trouble with this programming assignment for my Programming 2 class.  I feel a bit ashamed that I'm so lost since I seemed to excel in the prior class.  I apologize in advance for what is most likely a trivial problem, but I'm having trouble applying any solutions I find online to my specific code.  Long story short, I've got a Car constructor that has two strings for a make and model (i.e. Honda, civic, respectively).    public Car(String make, String model, double basePrice, String plateNum) {     this.make = make;     this.model = model;     this.basePrice = basePrice;     this.plateNum = plateNum; }   In order for the equals method to function, the cars must have the same make and model.  Here's what I keep messing with, but it always returns false.  @Override public boolean equals(Object other) {     if(!(other instanceof Car))         return false;      Car temp = (Car)other;       if(this.equals(temp.getMake()) &amp;&amp; this.equals(temp.getModel()))         return true;     else         return false; }   I've tried it without the "not" in front of the instanceof if statement, and I've tried inverting the this and temp, to no avail.  I know giving out answers to homework is frowned upon, and I understand it completely.  If not, perhaps someone could be kind enough to explain what I'm doing wrong?  I'm not entirely sure what "this" means.  I imagine that it is essentially a placeholder for what will be calling the method.  In this case, it would be a CarObject.equals.  Anyway, thank you again in advance.  This website has helped me out many times in the past, I'm looking forward to any replies. :)
What issues should be considered when overriding equals and hashCode in Java? What issues / pitfalls must be considered when overriding equals and hashCode?
We know the optimum angle for greatest horizontal displacement when launching an object with projectile motion is 45 degrees.  How to solve the angle when it is real long distance around the earth where we cannot assume that gravity is constant but is given by $F=\frac {-GMm}{r^2}$. I use differetial equation to solve it and obtain 45 degrees.   First, for the vertical distance $y$, change $v=u-gt$ to $y'=u-y''t$. Then solve it to obtain a function $y(t)$. When $y'(t)=0$ we have the time for maximum vertical distance. Then insert the value to horizontal equation.   Can anyone guide me through this problem because I am not confident with my working How did the ending happen from Neil's perspective? I am trying to figure out the scene near the finale of Tenet where Neil unlocks the door and gets shot in the face. I can't really see the flow where he opens and holds the door and the protagonist walks in and fights the bad guy. Can you tell the series of events as Neil sees them happen till he gets shot? UPDATE If I am not wrong, I see it like this: Neil was running down towards the door, both the protagonist and his mate are inside with the door locked fighting the bad guy, then, he unlocks the door and walks in and stands behind the door. The protagonist's mate comes out of the room, then the protagonist, then he closes the room, then he look back to get shot in the face. But this doesn't make sense, if he wanted to unlock the door when he was running down, they were already in fighting the bad guy!!!!! Name "Chapter" is not showed in the table of the content I would like to find all ellipses which contain 2 given points and has one focus at origin (zero). All in 2D plane.   There are several possible approaches but I'm not sure which is the best - both looks quite difficult to solve algebraically.   using polar equation relative to focus with $(R_1,\phi_1),(R_2,\phi_2)$, being coordinates of points $$ R_1 = \frac{a(1-e^2)}{1-ecos(\phi_1-\theta)} $$ $$ R_2 = \frac{a(1-e^2)}{1-ecos(\phi_2-\theta)} $$ then for given $\theta$ solve for semimajor axis $a$ and eccentricity $e$ using deffinition of elipse as a set of points of the same distance from both foci. Given 2 points of cartesian coordinates $(x_1,y_1),(x_2,y_2)$ and one focus in origin $(0,0)$. For each given distance parameter $L$ solve for coordinates of second focus $(x_f,y_f)$, $$ L = \sqrt{x_1^2 + y_2^2} + \sqrt{(x_1 - x_f)^2 + (y_1 - y_f)^2} $$ $$ L = \sqrt{x_2^2 + y_2^2} + \sqrt{(x_2 - x_f)^2 + (y_2 - y_f)^2} $$ I can also first rotate the coordinate system (or my input points) by given angle (which is my arbitrary parameter) and then use some simplified equation of ellipse which has major axis parallel to x-axis which has just 2 degrees of freedom. But even after this rotation I don't see much simplification of algebraic solution.    Or is there any better way?    The resulting equations are quite difficult to solve. I wonder if there is some trick to simplify it and make it more elegant.  Also, because I would later to implement it into computational code where it would be computed manytimes per second, I would prefer solution inf form which is fast to evaluate numerically ( prefferably without goniometric or any transcedental functions )    Why I'm interested ? - I need it for some optimalization of orbital transfers for spaceship orbiting the Sun. I asked also in physics.stackexchange, and people recomand me that I should rather go to math section. $\DeclareMathOperator{\card}{card}$From Problem-Solvers Topology  Prove the following: CANTOR'S THEOREM If $A$ is a set, then $$\card A &lt; \card \mathcal{P}(A)$$ where $\card A$ stands for the cardinality of set $A$.  My Answer If $A = \emptyset$, then $\card A =0$ and $\card \mathcal{P}(A)=1$. If $A = \{a\}$, then $\card A=1$ and $\card \mathcal{P}(A)=2$. So suppose that $A$ has at least two elements. Define a function $f: A \rightarrow \mathcal{P}(A)$ such that $f(x) = \{x\}$ for all $x \in A$. Then $f$ is injective. But it cannot be surjective, because for any two distinct elements $a,b \in A$, there is no element in $A$ that is sent to the set $\{a,b\}$ in $\mathcal{P}(A)$. Therefore, there is no bijection, and $\card A &lt; \card\mathcal{P}(A)$. Do you think my answer is correct? Thanks in advance Cardinality of cartesian product of an infinite set with N Here the problem 1.4.26 from Sohrab, Basic Real Analysis  Duplicate  This are not duplicate of this question:    the answer gives no proof  despite the title is not really connected  only finite set   Problem  Show that, if $A$ is an infinite set, then $|A\times\mathbb{N}|=|A|$. Hint: Let $\mathcal{F}$ denote the set of all bijective maps $f:S\times\mathbb{N}\to S$, where $S\subset A$. Since $|\mathbb{N}\times\mathbb{N}|=|\mathbb{N}|$, we have $\mathcal{F}\neq \varnothing$ (Why?) Show that Zorn's Lemma can be applied in $\mathcal{F}$ to produce a maximal bijection $h:B\times\mathbb{N}\to B$, with $B\subset A$, and that we must have $B=A$, by examining the cases where $S\setminus B$ is finite or infinite.  Proof  Let $\mathcal{F}$ denote the set of all bijective maps $f:S\times\mathbb{N}\to S$, where $S\subset A$. Since $|\mathbb{N}\times\mathbb{N}|=|\mathbb{N}|$ (see exercise 1.4.10(i)), we have $\mathcal{F}\neq \varnothing$ (From Exercise 1.4.22(d) we know that for a infinite set $A$, we have $|A|\geq\aleph_0$, and $|\mathbb{N}|=\aleph_0$, thus there is an injection from $g:\mathbb{N}\to A$, and, by defining $S:=g(\mathbb{N})\subset A$, we get a bijective map (composition of two bijective maps) $S\times\mathbb{N}\to\mathbb{N}\times\mathbb{N}\to\mathbb{N}\in\mathcal{F}$).  If we consider the inclusion as partial order, then every chain $S_i\subset A$, $i\in I$, has $A$ as upper bound and applying Zorn's Lemma, we get the existence of a maximal $\bar{S}$ and hence a bijection $h:\bar{S}\times\mathbb{N}\to\bar{S}$, with $\bar{S}\subset A$.  Now we prove that $\bar{S}=A$. $R:=A\setminus \bar{S}$. $\bar{S}$ is infinite, since the example of element of $\mathcal{F}$, that we gave above is bijective to $\mathbb{N}$. We have to do this. The second is trying to follow the hint and is incomplete:   Consider that $A\neq\bar{S}$, then there is $r\in R:=A\setminus\bar{S}$. We chose an element $s\in\bar{S}$ and define the bijection $h':\bar{S}\cup\{r\}\times\mathbb{N}\to \bar{S}\cup\{r\}$ as follow  $h'(a,n)=\begin{cases}h(s,2n-1)&amp;\text{for }a=s\\ r&amp;\text{for }a=r,n=1\\ h(s,2n-2)&amp;\text{for }a=r,n\neq 1\\ h(a,n)&amp;\text{otherwise}\end{cases} $  Since $\bar{S}\subsetneq \bar{S}\cup\{r\}$ we get a contradiction to the maximality of $\bar{S}$. Now either $R$ is finite or infinite. 1) $R$ finite, let say $R=\{r_1,\cdots,r_n\}$. Then chose $n$ elements $s_1,\cdots,s_n\in\bar{S}$ and we define the bijection $h':A\times\mathbb{N}\to A$ as follow $h'(a,n)=\begin{cases}h(a,2n-1)&amp;\text{for }a\in\{s_1,\cdots,s_n\}\\ a&amp;\text{for }n=1,a\in\{r_1,\cdots,r_n\}\\ h(s_i,2n-2)&amp;\text{for }a=r_i\\ h(a,n)&amp;\text{otherwise}\end{cases}$  In case $n&gt;0$ we get a contradiction with $\bar{S}$ being the maximal element.   Thus we have only to exclude the case 2) $R$ infinite. HOW TO DO THAT?   Question  Above I tried two proofs. The first part is the same. The two second parts are given by the two bullets.  The second proof tries to follow the hint.  My questions are:   - Is my proof correct?   - In which direction should go the proof from the hint? To prove that $(\mathbb{P(N)},d)$ is a metric space To prove that $(\mathbb{P(N)},d)$ is a metric space where $\mathbb{P(N)}$ is the power set of $\mathbb{N}$.  And $d:\mathbb{P(N)}\times \mathbb{P(N)} \mapsto\mathbb{R}$ is defined by $d(A,B)=\begin{cases} 0, &amp; \text{if A} \Delta \text{B=}\emptyset  \\ m^{-1}, &amp; \text{where m is the smallest member of} A\Delta B \end{cases} $.   Attempt: $x \in P\Delta Q=(P-Q)\cup(Q-P) \implies x\in (P-Q) \text{ or } x\in (Q-P) $. But $(P-Q)\cap(Q-P)= \emptyset \implies x \in P \text{ and} \notin Q \text{ or }x \in Q \text{ and} \notin P. \ \ \ $    (*)  To prove the triangle inequality:  Take any three sets $A,B,C \subset \mathbb{P(N)}$ such that none of them are equal to another. Now,  $\min A \Delta B  =m_1, \min B \Delta C  =m_2,  \min A \Delta C  =m_3   $. To prove $d(A,B) \leq d(A,C)+ d(B,C)$. By (*), $m_1 \in A$ or $m_1 \in B$ but not both.   Again,  $m_2 \leq m_1$  or $m_3 \leq m_1$. Either way, we are done. When $A \neq B$ and either $B =C $ or $A=C$ (not both), we have respectively $A=C$ , $B=C$ . Which satisfies the triangle inequality. When $A=B$ it is evident.   Symmetry: We know $A \Delta B =B \Delta A$. $d(A,B)= d(B,A)$  Non-negativity and $0 \iff A=B$:   $d(A,B)=0 \iff A \Delta B= \emptyset \iff A \subset B \text{ and } B \subset A \iff A=B$. By definition $d(A,B) \geq 0$  Is this okay? Please verify. In the  question one of the answers had the following code snippet:  IEnumerable&lt;object&gt; FilteredList() {     foreach(object item in FullList)     {         if(IsItemInPartialList(item))             yield return item;     } }   What does the yield keyword do there?  I've seen it referenced in a couple places, and one other question, but I haven't quite figured out what it actually does.  I'm used to thinking of yield in the sense of one thread yielding to another, but that doesn't seem relevant here. Is it a good practice to refer to countries, ships etc using the feminine form? While talking about ships and countries, is it a good practice to use the feminine form?  For example:  "Her economy" - while referring to a country's economy "Her flag (or deck etc)" - while referring to a ship  Is this practice common? Is it used today? Is the 64-Bit version of Ubuntu only compatible with AMD CPUs? I was told that computers with more than 2 gig's memory need a 64 bit operating system to utilize all RAM.  Is the 64bit Ubuntu download really JUST for AMD processors? I am asking because the disk image I downloaded says AMD64.  So will my new Intel 2.3Ghz Core i3 Dual Core processor work with 64 bit Ubuntu?  It runs the 64bit version of Windows without any qualm. How do I integrate Github files to Orange for ML? I am currently trying to make a facial recognition workflow with Orange but since the widgets are still prototypes they are not all available in Orange. I found the Github files for the widgets but don't know how to install this so that I can see and use the widgets in Orange. Robot arm move a box What makes matter travel along geodesics? The relativistic explanation of gravity is geometric, the motion of a body in a field of space-time distortion can be described as being at rest and travelling along a geodesic of that field, but why does it travel along that geodesic? What causes it to move? How to make IntelliJ IDEA recognise code created by macros? Which is the correct tense to use with 'by'? I gave him the money by 6 PM.   I had given him the money by 6 PM.   I can't spot the difference between them and both seem right, but I was told the first one is wrong. Can anyone say, why?  Here is a another set of sentences with the same issue:     By 5 PM I gave him the book.   By 5 PM I had given him the book.   In both the sentences the book was given before 5 PM and no later than 5 PM. But I can't understand then what the difference between them is.   Is it right to use simple past with 'by' at all? If yes, then why and if not, then why is it incorrect to use simple past with 'by'? How does one solve the matrix equation $AX+XB=C$ for $X$? It doesn't seem too difficult. I tried many times but failed.  I'm an adult student... I am now vexed about Gilbert Strang - An Introduction to Linear Algebra. I don't even understand a single word in Wikipedia: . If you have ever use some nice workable materials or lecture notes? You can generously upload and share the links of the lecture notes and assignments. Different subjects/ topics are welcome, as long as you deem they are nice and workable.   The problem origins from a system of diff equation, using undetermined coefficients (matrix) to find the particular solution. Try $y_p=X\begin{pmatrix}   e^{\alpha t} \\ e^{\beta t} \end{pmatrix}$  $\dot{y}+Ay=C\begin{pmatrix} e^{\alpha t} \\ e^{\beta t}\end{pmatrix}$   $\dot{y_p}=X\begin{pmatrix} \alpha &amp; 0 \\ 0 &amp; \beta \end{pmatrix} \begin{pmatrix}e^{\alpha t} \\ e^{\beta t}\end{pmatrix}$  substitute $\dot{y_p}$ and $y_p$ into the original differential equation..  $X\begin{pmatrix} \alpha &amp; 0 \\ 0 &amp; \beta \end{pmatrix}+AX=C$ Let $u:\mathbb{C}\rightarrow\mathbb{R}$ be a harmonic function such that $0\leq u(z)$ for all $ z \in \mathbb{C}$. Prove that $u$ is constant.  I think i should use Liouville's theorem, but how can i do that? Help! Tentative definitions in C and linking Safely moving and creating new tempdb files Two things I'd like to know:   how do you safely move tempdb with minimal downtime? how many tempdb files do you need?   Is it 1 file per core? So quad-core = 4 tempdb files, creating three new ones? Really stuck with this, \begin{cases}  2tx'(t)-1=x^2t \\  x(t=1)=1 \\  \end{cases} I don't understand the variables. What does it mean that $x$ differentiated have $t$ as a function value, like this: $x'(t)$? Don't get it :(