Hi, I need to write a system that simulates buying and selling on the stock market with just text outputs. I need to create a menu so the user can register and delete thier account. Also be able to buy and sell shares.

So far I have my classes and attibuttes

public class User
{
    private int Id;
    private String name;
    private double trade;
}
public class Share
{
    private String code;
    private int quantity;
    private double price;
}
public class Trade 
{
    private LinkedList<Share> shares = new LinkedList<Share>();
    private LinkedList<User> users = new LinkedList<User>();
}

My plan is to create the users and shares in the Trade class, and write the methods for register, delete, sell and buy in the trade class as well. I will then call these methods in a Menu class.

I'm not sure if this is the right appoarch in writing this program. Can you guys help me if my classes and attributes are right thanks.

Not a bad start. You may be missing one class because your Trade class represents both individual Trades (buy/sell), but also has the list of Users and Shares. Users and Shares belong to a StockMarket. In the StockMarket you can register and delete Users and Shares, and create many Trades. Every Trade represents on a given date, one User buying a quantity of a Share from another User for a given price. (Which is the same as selling when seen from the second User's viewpoint.)
Now have a second look at the atributes - eg a Share's bid and offer prices keep changing, and maybe they aren't important to this application, but every Trade is done at a definite price that never changes. eg a User may have made many Trades...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.