Skip to content

Commit 62b9382

Browse files
committed
Merge branch 'main' of github.com:rohanrajpal/advanced-programming-tutorials into main
2 parents 809883f + ea7ebf0 commit 62b9382

File tree

8 files changed

+260
-147
lines changed

8 files changed

+260
-147
lines changed

tut-5/Main.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static void main(String[] args) {
4444

4545
int x = takeIntInput(), y = takeIntInput();
4646

47-
if(prev.containsKey(new Pair(x, y))) // hashmap check, hashcode depends only on name, value
47+
if(prev.containsKey(new Pair(x, y))){ // hashmap check, hashcode depends only on name, value
4848
System.err.println("Can't input same coordinate again,enter again");
4949
j--;
5050
continue;

tut-6/Main.java

+45-21
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,6 @@ public static void main(String[] args) {
66

77
Database db1 = new Database();
88

9-
System.out.println("1.Administrator\n" +
10-
" a. Insert product/category\n" +
11-
" b. Delete product/category\n" +
12-
" c. Search product\n" +
13-
" d. Modify product\n" +
14-
" e. Exit as Administrator\n" +
15-
"2.Customer\n" +
16-
" a. Add funds (assume all integer operations)\n" +
17-
" b. Add product to the cart\n" +
18-
" c. Check-out cart\n" +
19-
" d. Exit as Customer\n"+
20-
"3. Exit");
21-
22-
23-
249
Admin a1 = new Admin(db1);
2510
// Customer m1 = new Customer(0, db1);
2611
// a1.InsertProdCat("a>b>f", "h", 2, 2, 1);
@@ -51,22 +36,45 @@ public static void main(String[] args) {
5136
// System.out.println("testing");
5237

5338
while(true){
39+
System.out.println("1.Administrator\n" +
40+
" a. Insert product/category\n" +
41+
" b. Delete product/category\n" +
42+
" c. Search product\n" +
43+
" d. Modify product\n" +
44+
" e. Exit as Administrator\n" +
45+
"2.Customer\n" +
46+
" a. Add funds (assume all integer operations)\n" +
47+
" b. Add product to the cart\n" +
48+
" c. Check-out cart\n" +
49+
" d. Exit as Customer\n"+
50+
"3. Exit");
51+
// System.out.println("Enter Option");
5452
int opt = takeIntInput();
5553
if (opt == 1){
5654
int fl=1;
57-
5855
while (fl==1) {
56+
System.out.println("Administrator\n" +
57+
" a. Insert product/category\n" +
58+
" b. Delete product/category\n" +
59+
" c. Search product\n" +
60+
" d. Modify product\n" +
61+
" e. Exit as Administrator");
62+
// System.out.println("Enter Option");
5963
String opType = sc.next();
6064
switch (opType) {
6165
case "a":
6266

6367
System.out.println("(a)Product or (b)Category?");
6468
String inp = sc.next();
69+
System.out.println("Enter path of product/category");
6570
String path = sc.next();
6671
if (inp.equals("a")) {
72+
System.out.println("Enter product's name");
6773
String productName = sc.next();
68-
System.out.println("Enter product's price and details");
69-
int price = takeIntInput(), UnitsAvail = takeIntInput();
74+
System.out.println("Enter product's price");
75+
int price = takeIntInput();
76+
System.out.println("Enter product's no of available units");
77+
int UnitsAvail = takeIntInput();
7078

7179
a1.InsertProdCat(path, productName, price, UnitsAvail, 1);
7280
} else {
@@ -76,20 +84,27 @@ public static void main(String[] args) {
7684

7785
break;
7886
case "b":
87+
System.out.println("Enter path of product/category");
7988
path = sc.next();
8089
a1.delete(path);
8190

8291
break;
8392

8493
case "c":
94+
System.out.println("Enter name of product to search");
8595
String productName = sc.next();
8696
a1.search(productName);
8797

8898
break;
8999

90100
case "d":
101+
System.out.println("Enter name of product to modify");
91102
productName = sc.next();
92-
a1.Modify(productName, takeIntInput(), takeIntInput());
103+
System.out.println("Enter product's new price");
104+
int price = takeIntInput();
105+
System.out.println("Enter product's new no of available units");
106+
int UnitsAvail = takeIntInput();
107+
a1.Modify(productName, price, UnitsAvail);
93108

94109
break;
95110

@@ -106,17 +121,26 @@ else if (opt == 2){
106121
int fl = 1;
107122
Customer m1 = new Customer(0, db1);
108123
while (fl == 1) {
124+
System.out.println("Customer\n" +
125+
" a. Add funds (assume all integer operations)\n" +
126+
" b. Add product to the cart\n" +
127+
" c. Check-out cart\n" +
128+
" d. Exit as Customer");
129+
// System.out.println("Enter Option");
109130
String opType = sc.next();
110131
switch (opType) {
111132
case "a":
133+
System.out.println("Enter funds to add");
112134
int ToAdd = takeIntInput();
113135
m1.incfunds(ToAdd);
114136

115137
break;
116138
case "b":
139+
System.out.println("Enter product's name");
117140
String ProdName = sc.next();
118-
119-
m1.addProduct(ProdName, takeIntInput());
141+
System.out.println("Enter product's quantity");
142+
int quantity = takeIntInput();
143+
m1.addProduct(ProdName, quantity);
120144

121145
break;
122146
case "c":

0 commit comments

Comments
 (0)