File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
reader/ReadingJava/Programs Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 11
2+ // Make Bookstore class a "collection" class. It should have an array of Books.
3+ // Add a method to add a Book to the array.
4+ // Add a method to search for the price of a book given its title.
5+ // Add a method to search for the titles of all books written by a given author.
6+ // Add a method to search for the titles of all books with a price below a given amount.
7+
8+ // Make a Main class that creates a Bookstore object and tests all the methods.
9+
210class Author
311{
412 private String fName ;
@@ -93,4 +101,8 @@ public static void main(String[] args)
93101 Book2 .setPrice (735 );
94102 System .out .println ("Title : " + Book2 .getTitle () + "\n Author : " + Book2 .getAuthor () + "\n Price : Rs " + Book2 .getPrice ());
95103 }
96- }
104+ }
105+
106+ // Change public class Bookstore to just a class Bookstore
107+ // Make Main a `public class` with a main method that creates a Bookstore object and tests all the methods.
108+
Original file line number Diff line number Diff line change 2525 *
2626 ******************************************************************************/
2727
28+
29+
30+ // This needs to be Re-Factor'd
31+ // This is a simple program that deals 5-card hands at random to the given number of players.
32+ // It needs to be generalized, so that it can be used for any number of players and any number of cards per player.
33+ // Also the blocks of code in `main` should be broken down into methods.
34+ // the code is not well-organized, and it is not clear what the code does.
35+ // the SUITS and RANKS arrays should be declared as constants. And outside of the main method.
36+
37+
2838public class Deal {
2939 public static void main (String [] args ) {
3040 int CARDS_PER_PLAYER = 5 ;
3141
3242 // number of players
3343 int PLAYERS = Integer .parseInt (args [0 ]);
44+ // what does this ^^^^ mean?
3445
3546 String [] SUITS = {
3647 "Clubs" , "Diamonds" , "Hearts" , "Spades"
You can’t perform that action at this time.
0 commit comments