• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do you practice?  RSS feed

 
Ahmad Auada
Ranch Hand
Posts: 56
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was about to dive into android developments, but after a few chapters I felt that I need some more practice with java.
Where can I find exercises? I tried codingbat.com, but the questions are all about algorithms and not object oriented concepts, and the latter is where I need most practice.

Any books? Websites may be? I tried googling this but not sure where to go
Also where can I find java programs made by other people with the source code?
 
Knute Snortum
Sheriff
Posts: 4288
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to practice OOP then the coding sites like Hackerrank are probably not the best. How about creating a project for yourself?

You could create a little bank transaction system with Bank, Account, Transaction, etc.

A TicTacToe game with Player, Board, Game, etc.

If you like cars, how about a software car with Car, Body, Transmission, Engine, Brakes, etc.

Or anything else you might want to do.
 
Ahmad Auada
Ranch Hand
Posts: 56
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:If you want to practice OOP then the coding sites like Hackerrank are probably not the best. How about creating a project for yourself?

You could create a little bank transaction system with Bank, Account, Transaction, etc.

A TicTacToe game with Player, Board, Game, etc.

If you like cars, how about a software car with Car, Body, Transmission, Engine, Brakes, etc.

Or anything else you might want to do.


I tried to build a virtual asstiant, but I'm not sure that I applied the oop concepts correctly. Thats why I want some exercises with answers, or atleast some programs with the source code made availble
 
Knute Snortum
Sheriff
Posts: 4288
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know if this is the best place for code review, but if you post your code to GitHub, I'd be happy to take a look at it.
 
Ramsin Khoshaba
Ranch Hand
Posts: 65
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I present you a problem from which you can learn a lot if you are a beginner.
I hope I haven't missed some important details.

Definitions:
A polyline is a line composed of one or more edges (line segments). An endpoint is a vertex.

Problem:
Create a class that models a 2-dimensional point, that has:
1. a name, x-coordinate, and y-coordinate
2. two constructors:
public Point(String name, int x, int y)
public Point(Point P)
3. getter and setter methods
4. an instance method that returns the distance between this point and another point
5. equals() and toString()

Now make a polyline class that makes use of your Point class. Your polyline class has to implement the following interface:

Furthermore, have these two constructors:
public PolylineClassName () // choose a good class name
public PolylineClassName (Point[] vertices)

And a toString() method would be also good.
You can now test your classes in a main method.

What you will learn:
1. interfaces
2. iterators
3. the Iterator<E> interface, here is an introduction: https://www.youtube.com/watch?v=zALZ_8epoQ0
4. anonymous classes
5. how to override and implement equals() properly
6. how to implement getter methods properly so that they don't violate encapsulation
etc...

If you want an extra challenge, you may implement another polyline class using a linked list.
Also, if you need a problem on inheritance and nested and abstract classes, tell me.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!