I know this may be a bit too much to ask, but I would like for someone to check my program if they could, and to tell me a few things i could improve. This program combines my knowledge of Java with OOP concepts at the moment(excluding some stuff liek inheritance), and before I take the next step, I would like to see if there was anything i could have done better (which i know there is). I don't want to code incoherently (spaghetti code), and I want to be effecient and simple as possible. Its sort of a booking program. oh yeah, dont be nice
So please, any suggestions on my program please let me know. Everything does compile and runs fine.
Your code here will only check the first seat. So if three people are booked, there is still a seat left, but this method will return false. Have your learned Collection classes here. You could use and ArrayList, and just check the length, if it is 4 then it is full.
3). I'd make all your instance variables private to ensure proper encapsulation.
4). In Bus.addCust, you are always resetting your seatcounter to 1 each time, What is your intention with the seatCounter (proper naming standard here)? It is only used in this method, so I would declare the variable inside the method instead of making it a static member of the Class. Probably the same with shuttleCounter.
- in printOrder, use a StringBuffer or StringBuilder (5.0) to aggregate the fullorder text. - isolate user interface from your model classes. For example, Bus shouldn't use JOptionPanes. Push as much "business" logic into Bus and other model classes as possible. - don't use hardcoded literals ("magic numbers"), such as 4.
Don't use "static" except for its intended purpose of sharing something among all instances of a class. You've used "static" here in a classic "newbie" way, basically making everything in the Talk class static so they're easy to get to from "main()". Instead of doing this, make everything non-static, and then replace main's body with
I'd like to comment, but your code is nearly unreadable in my browser because of the heavy indentation. If you could fix that...
You can edit your post by using the "pen and paper" icon at its top.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus