README.md
*************************************************
APP OVERVIEW
*************************************************
Use cases:
1) User creates offline list of items that will be used in an auction, example:
- sofa, pale blue, heavily used #sofa001
- mountain bike, barely used (I am developer not a sportsman) #bike002
- HTC ONE, Android phone, still working, AT&T #phone003
2) User distributes the list of bid items to FFF (family, friends and fools) by mailing, posting, etc.
3) User enters the bid items into the app
4) User enters the bid deadline per item into the app
6) User enters a minimum bid price per item into the app
7) FFF send SMS messages with bid in format:
bid #bike002 $30
8) The app tally up the highest bid and replies to FFF
- Minimum bid for item #bike002 is $30
- These is a higher bid for #bike002 in amount of $31
9) User can monitor the winning bids in the app
#sofa001
No bids
#bike002 minimum bid $30
- $31 from 6508151234
- $30 from 6508151432
10) there are many additional features you can add to this application
Step 1) Copy appSMS
We will use the previous app we wrote as a starting point.
Synch the class GIT repo:
- git fetch
- git add -all
- git commit -m "my previous changes xyz"
- git rebase
- git push
You can copy the version committed by the instructor to your desktop and then "Import Module" in AndroidStudio
Name it appSMSBid
Step 2) Rename the app in res/values/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">"SMS Auction"</string>
<string name="action_settings">Settings</string>
</resources>
Step 3) Change the package name (app unique identifier)
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.chicagoandroid.android.app.sms.bid">
Step 4) Move classes
- Create new package bid
- Move classes to package com.chicagoandroid.android.app.sms.bid
Step 5) Run the app
adb shell 'pm list packages -f' | grep /data/app/com.chicagoandroid.android.app.sms
Step 6) see what class apps you have running
$ adb shell 'pm list packages -f' | grep /data/app/com.chicagoandroid.android.app
package:/data/app/com.chicagoandroid.android.app.sms-1.apk=com.chicagoandroid.android.app.smspackage:/data/app/com.chicagoandroid.android.app.json.weather-1.apk=com.chicagoandroid.android.app.json.weather
Step 7) Create a new Java class BidItem.javaAdd constructor:
BidItem(String itemID, double minBidPrice, String description) {
this.setDescription(description);
this.setItemID(itemID);
this.setMinBidPrice(minBidPrice);
}
Override default toString method:
@Override
public String toString() {
StringBuffer output = new StringBuffer(150);
output.append("itemID: " + getItemID() + ", ");
output.append("description: " + getDescription() + ", ");
output.append("minBidPrice: $" + getMinBidPrice());
return output.toString();
}
Step 8: Create Java class Bid
constructor:
Bid(String bidID, double bidAmount, String personNumber) {
this.setBidID(bidID);
this.setBidAmount(bidAmount);
this.setPersonNumber(personNumber);
}
constructor:
Bid(String bidID, double bidAmount, String personNumber) {
this.setBidID(bidID);
this.setBidAmount(bidAmount);
this.setPersonNumber(personNumber);
}
Step 9: Create class BidEngine
package com.chicagoandroid.android.app.sms.bid;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by uki on 12/6/14.
*/
public class BidEngine {
/** A collection of BidItems indexed by itemID **/
private Map<String, BidItem> bidItems;
private List<Bid> bids;
BidEngine() {
createMockBidItems();
createMockBids();
}
//TODO public void addItem(BidItem)
//TODO public void removeItem(BidItem)
//TODO public void changeItem(BidItem);
public Map getBidItems() {
return this.bidItems;
}
private void createMockBidItems() {
bidItems = new HashMap<String, BidItem>();
BidItem sofa = new BidItem("sofa001", 15.00, "sofa, pale blue, heavily used");
bidItems.put(sofa.getItemID(), sofa);
BidItem bike = new BidItem("bike002", 50.00, "mountain bike, barely used (I am developer not a sportsman)");
bidItems.put(bike.getItemID(), bike);
BidItem phone = new BidItem("phone003", 30.00, "HTC ONE, Android phone, still working, AT&T");
bidItems.put(phone.getItemID(), phone);
}
private void createMockBids() {
bids = new ArrayList<Bid>();
Bid sofa1 = new Bid("sofa001", 15.00, "6508151234");
bids.add(sofa1);
Bid sofa2 = new Bid("sofa001", 16.00, "6508151232");
bids.add(sofa2);
Bid sofa3 = new Bid("sofa001", 17.00, "6508151234");
bids.add(sofa3);
}
public String printMyBidItems() {
StringBuffer output = new StringBuffer();
for (BidItem item : bidItems.values()) {
output.append(item.toString() + "\n");
}
return output.toString();
}
}
Step 10: Create initial UI