So I’ve already listed out the things in the constructor. Now I am trying to define the string in a the “public string x()” method.
This is what I mean by this:
private String cardName() {
switch (number) {
case 13: return “King”;
case 12: return “Queen”;
case 11: return “Jack”;
case 1: return “Ace”;
default: return “” + number;
}
The above is an example code given to me but in my case I need to list out a specific thing which was defined in the constructor of another class. Any of you guys would be able to help me?
Basically instead of returning a string to me, it returns me an integer but because I used an integer variable and not a string variable. So how would I need to modify the above code to make it work for a string variable?
Thanks in advance.
Information on this topic can be found here:
https://stackoverflow.com/questions/6576…m-another-class
https://stackoverflow.com/questions/1022…m-another-class
https://docs.oracle.com/javase/tutorial/…nstructors.html
Also, you can look at the sample of a gravity calculator, in which you can also figure out how to manage classes and functions. I hope that you found this java sample useful and it will help you to cope with your own project.