Lg Long

Ranch Hand
+ Follow
since Feb 29, 2020
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
20
Given in last 30 days
20
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Lg Long

Hi,

Thank you for your help.

I was thinking of something else, that is why I became confused. All I had to do in my Controller model, was to print the get score in case 1 and 2.

The structure for TennisGame project: TennisGame(model); TennisMenu(controller); Main(view)

I can't stop thinking of the model I did for the Natural Reserve project, where I learned how to use build a model - Pojo, controller, I had a Factory for the name of the bird to be what I wanted to be called, the Controller was the NaturalReserver class, having methods such as add, retrieve, count etc in it; the View was the menu& Scanner and Main was just an entry point.

Ex: Player(model), TennisGame(controller), TennisMenu(view), Main(program entry point)


Any suggestions on ho to refractor this project to the same structure as above. O why not do it?
15 hours ago
So, i have my model solved. Can I get some help with the controller, please?
I don't have a picture of what should look like in this example.
I could use some code for starters. Maybe empty methods?

I'll try one more time to help you organise your thoughts. You need to implement MVC and you've actually started down a good path with that. You already have code for a Controller, that's the game loop that you kind of patterned after an example I gave. Here's a breakdown of responsibilities of different classes that would make up MVC:

View (GameView class)
1. Displays menu
2. Gets input from user
3. Displays status of the game (as provided by the model, through the controller)

Controller (GameController class)
1. Tells the View to display menu
2. Tells the View to get user input (the action)
3. Dispatches user input to appropriate actions
4. Calls appropriate methods in the model to carry out actions requested
5. Passes results of the action performed back to the view for display, if any.

Model (Game class)
1. Keep track of the state of the game - keeps score and determines if game is over
2. Provide methods to change the state of the game - serverWinsPoint(), receiverWinsPoint()
3. Provide method to report the state of the game (getScore(), hasWinner())

That's it! With the four menu options you're supposed to provide to the user (1-Award server a point, 2-Award receiver a point, 3-Show score, 4-Exit) you have everything in the above description to implement a program that does all that.

2 days ago
ok. as I said before, I am pressured by time and as much as i want to learn I need to sort this out so I can pass my assessment.
sometimes you need to lose a battle to win the war, and this is a battle that I can lose to gain more time to learn. If I fail, it won't matter that I did this by myself or not.

It's fine. I'll find another way. Thank you for the help
2 days ago

you're not treating a point value of 4 as a special case.



how can I do that?
can I please get some coding examples?

all I get pesudo explanations and i don't have experience enough to interpret all this

I don't have a direction, example other exercises to tie too. This is really frustrating
2 days ago
This is my atAdvantagePoint



I don't know how to write the isServerUp() -> can I get some help?




also I need to take one instance of server and receiver out, else I get the java.lang.ArrayIndexOutOfBoundsException: 4

2 days ago
posted 2 times as the platform was loading and I submitted the same post.
please delete.
3 days ago
   Work aside and type for a joke: I eat allot. My friend is asking how can I do that and remain supple. I said "the brain consumes a lot of energy. The dumbest the more. Stay dumb. Stay skinny "

       I was about to write the whole 'if it works let me be for now'. But I run the test and I get null, lol.

       ok, this is my code so far. It is screwed. As soon as I try to pass:



failing:
it_gives_receiver_score_second()
Expected :15 - Love
Actual   :Ad out

it_gives_receiver_score_second()
Expected :15 - Love
Actual   :Ad out

it is Ad in when deuce and server wins point()
java.lang.ArrayIndexOutOfBoundsException: 4


Please no more riddles, I can't focus anymore and I need to finish. Could use some straight forwards examples, from which to pick answers. I can barely read your explanations. By the time I finish I am more confused then when i started
3 days ago
Ok, I get it. The story of the winner() method tells if the player wins or not. One responsibility

I will find myself in a not later on when doing the Add in Add on, because of my conditions, will I?

is this what you meant by the code:


3 days ago

Junilu Lacar wrote:I really hope you can look at the critiques I've given as constructive criticism. Again, everything I've suggested was given with the hope that you'd see a better way out of your current situation. But then again, it seems I've pushed you beyond your limit and maybe it's my turn to give it a rest now.  Good luck.



You did, that's what coaches do. So thank you. And be sure that I take all the critique in a healthy way.
So, be sure I think of you with appreciation!

I am also working, so I have to solve other problems too. That is why my energy is divided.
Going for a walk now. Will continue when I come back!
3 days ago
Nope, you are my hero rancher!


Was working on it. I do get confused a lot. And I can't remember what I did wrong or good.
Should be tough on you too to see me struggling and not giving up. Good that I still have time, I should finish by tomorrow, otherwise I won't be able to study all I've done.

3 days ago

1. you can simplify the formula SCORE[serverPoints].equalsIgnoreCase(SCORE[receiverPoints]) even further. Also, it's a formula. I already showed you (and you even quoted it recently) how to refactor so the code expresses the IDEA behind the formula. What does that expression mean? And if SCORE[serverPoints] is the same as SCORE[receiverPoints], what does that imply about serverPoints and receiverPoints?




I am going down on my concentration, so unless it is of outmost necessity to simplify even more. I will invoke 'if it works it is good enough'. otherwise, help.
If you give me a better answer I don't think you brake the rules of the ranch, I came up with a solution. I am a noob, it is pointless to tore me apart. I understand it is correct.
But following the rules doesn't need to be in a pedantic way
Code, does.
3 days ago


So remove duplication NOW.





I am confused on this. It seams as I need to create 2 methods:
     
So, in my understanding winner(), checks for rulles and the we have a boolean method called hasWinner??
3 days ago


What I'm getting at is that you can reduce the three specific if-statements you have now down to one general if-statement that covers all three cases. And it will be much simpler than any of the expressions you have now.



Hope I am going to finish tmrw. First finish then remove duplication Thank you for today.
4 days ago


@FunctionalInterface
interface Procedure {
   void run();

   default Procedure andThen(Procedure after){
       return () -> {
           this.run();
           after.run();
       };
   }

   default Procedure compose(Procedure before){
       return () -> {
           before.run();
           this.run();
       };
   }
}



This is what you've used to spare you duplicating code. For now I will stick with duplication



   public String getScore() {
       if (hasWinner()) {
           return winner();
       }
       if (isTied()) {
           return isDeuce() ? "Deuce" : tiedScore();
       }
       if (atAdvantagePoint()) {
           return isServerUp() ? "Ad in" : "Ad out";
       }
       return normalScore();
   }




This is where I need to change my present method getScore to normalScore and build the new method getScore() with the new methods in it.
4 days ago
Code up to date with tests passing





Next batch of tests to pass

4 days ago