The instance variables should be a character named letter and an integer named value.
Paul Clapham wrote:You could use a String to represent a character; that would certainly work if you made sure the value always contained exactly one character, no more and no less. But Java also has a data type which is used specifically to represent a single character so it would (I believe) be preferable to use that data type rather than String.
Junilu Lacar wrote:The requirements state that for a Tile, the letter should be a character and the value an integer. What reason do you have for not following this instruction?
Lexi Turgeon wrote:I thought that by changing the letter to a string I could give it a character, but I am not entirely sure how to do that.
Paul Clapham wrote:
Lexi Turgeon wrote:I thought that by changing the letter to a string I could give it a character, but I am not entirely sure how to do that.
Sure you can. Do you know how to represent a character in Java?
Junilu Lacar wrote:A quick search for how are characters represented in Java can tell you.
Also, the printTile method is supposed to take a Tile object as its parameter. Why do you keep flouting the requirements you have been so clearly given?
Fred Kleinschmidt wrote:But the instructions say to make the variable "letter" a character, and the variable "value" an integer. So why do you keep declaring "letter" as a double or a String, and "value" a double ?
Lexi Turgeon wrote: I thought I was doing it as the requirements said, I did not do it to be wrong on purpose.
No.Lexi Turgeon wrote:By declaring it as a string and giving it a value?
Campbell Ritchie wrote:
No.Lexi Turgeon wrote:By declaring it as a string and giving it a value?
I am getting the feeling of going round in circles. Your instructions were to record the letter as a character. Paul C pointed out that you are not so doing because you had a String. He asks whether you know how to record a character, so you asked whether to use a String.
How much teaching have you had from your online course? Have you been taught about different data types? How much of it have you actually done? Have you missed lots of the course?
Remind yourself of the primitive data types in the Javaâ„¢ Tutorials.
[edit]Add quote to beginning of post.
Junilu Lacar wrote:Lexi, please follow the links that have been provided to you for more information that will help you do the right thing per the requirements. You don't need to keep defending your mistakes, just learn from them and move forward. We're not being critical to be mean, we're trying to help you recognize what you need to improve.
We all recognize that programming doesn't come easily to everyone but you also need to understand that it can be frustrating to folks who try to give you tips which seem to be ignored. Again, if you follow the links to the tutorials, you'll find information about how characters are represented by their own primitive type in Java, and it's *not* String.
Lexi Turgeon wrote:
Junilu Lacar wrote:... follow the links to the tutorials, you'll find information about how characters are represented by their own primitive type in Java, and it's *not* String.
I did check it out, and did not find it too useful. Sorry.
Junilu Lacar wrote:
Lexi Turgeon wrote:
Junilu Lacar wrote:... follow the links to the tutorials, you'll find information about how characters are represented by their own primitive type in Java, and it's *not* String.
I did check it out, and did not find it too useful. Sorry.
Well, you'll have to look harder. It's there but we won't do your work for you.
Paul Clapham wrote: So why don't you see if you can find that example, for a start?
The instance variables should be a character named letter and an integer named value.
Paul Clapham wrote:Your code still doesn't match that part of the requirements, does it? What is the next step you would have to take to fix that?
Write a method named printTile that takes a Tile object as a parameter and prints the instance variables in some reader-friendly format.
Paul Clapham wrote:Now you already wrote a method named printTile but you didn't make it have a Tile object as a parameter. So let's see if you can fix that.
Paul Clapham wrote:There you had two parameters, the first being a char and the second being an int. Now look at your latest attempt and identify how your parameter declaration there differs from the parameter declarations in your first try.
Write a method named printTile that takes a Tile object as a parameter...
All things are lawful, but not all things are profitable.
Lexi Turgeon wrote:the steps I have completed are as follows:
- Write a definition for a class named Tile that represents Scrabble tiles. The instance
variables should be a character named letter and an integer named value.
- Write a constructor that takes parameters named letter and value and initializes the
instance variables.
- Write a method named printTile that takes a Tile object as a parameter and prints the
instance variables in some reader-friendly format.
Henry Wong wrote:
I hate to add more bad news... since this topic has already mentioned that you did step two *and* step three incorrectly.
Unfortunately, you also did step one incorrectly too. Considering that you are only learning Java, and likely don't know what is an "inner class" is yet; I highly doubt that your instructor wanted you to implement the class as an inner class.
Henry
Lexi Turgeon wrote:With those two things in mind:
Lexi Turgeon wrote:
So, the whole thing is wrong?
Henry Wong wrote:
Lexi Turgeon wrote:With those two things in mind:
Yes, but do you understand why? Or are you simply guessing based on the very detailed hints provided by Knute?
Henry
Correct. Just one thing, Java is case sensitive, so it isn't a tile, but Tile (T capital).Lexi Turgeon wrote:Yes, I understand that like a String, I need to use tile because it is a type.
- Write a constructor that takes parameters named letter and value and initializes the
instance variables.
Lexi Turgeon wrote:Would I take the number and letter I had previously put in so that there is no set value to them?
Please enjoy this holographic presentation of our apocalyptic dilemma right after this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|