id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
02c4271e-f9e4-4128-ae2b-ec924bc835fe | public void testOneSearch(){
Trie t = new Trie();
assertEquals(true, t.addWord("georgel"));
assertEquals(true, t.searchWord("georgel"));
} |
33d74d62-4612-4424-b02d-8e498bf0fb75 | public void testMultipleSearch(){
Trie t = new Trie();
assertEquals(true, t.addWord("georgel"));
assertEquals(true, t.searchWord("georgel"));
assertEquals(true, t.searchWord("georgel"));
assertEquals(true, t.searchWord("georgel"));
assertEquals(true, t.searchWord("georgel"));
assertEquals(false, t.searchWord("george"));
assertEquals(false, t.searchWord("eorgel"));
assertEquals(true, t.addWord("georgel"));
assertEquals(true, t.addWord("george"));
assertEquals(true, t.searchWord("george"));
assertEquals(false, t.searchWord("georg"));
assertEquals(false, t.searchWord("eorge"));
} |
d077298f-0472-49e3-af4f-077f30d27a2a | public Index(Table t, String... names) {
int irow = -1;
for (Row row : t.rows) {
++irow;
Key key = new Key();
for (String name : names) {
try {
key.add(row.get(name));
} catch (Exception e) {
System.out.println(row);
}
}
if (this.index.containsKey(key)) {
this.index.get(key).add(irow);
} else {
List<Integer> list = new ArrayList<Integer>();
list.add(irow);
this.index.put(key, list);
}
}
this.names = names;
this.table = t;
} |
3c6e6791-c023-4d9e-b7cf-3dcfd212201c | public Set<Key> getKeys() {
return this.index.keySet();
} |
8bd9b188-3f13-43b4-818e-71064a291a7c | public boolean containsKey(Key key) {
return this.index.containsKey(key);
} |
37c5e7d1-f4f3-41b4-9adb-7c258d6fed72 | protected Key buildKey(Object... vals) {
Key key = new Key();
if (this.names.length != vals.length)
throw new IllegalArgumentException("Zu wenig Argumente");
for (Object val : vals) {
key.add(val);
}
return key;
} |
086e7090-901b-482f-a466-4ce8ca612775 | protected Key buildKey(String... vals) {
Key key = new Key();
if (this.names.length != vals.length)
throw new IllegalArgumentException("Zu wenig Argumente");
for (int i = 0; i < vals.length; ++i) {
key.add(this.table.getBuilder(this.names[i]).build(vals[i]));
}
return key;
} |
0e3ef3c7-a849-4f74-9a9d-505becb240de | public List<Integer> getIndex(Key key) {
return this.index.get(key);
} |
45f494e8-8648-4c8a-b722-2197e8eae657 | public List<Integer> getIndex(Object... vals) {
return getIndex(buildKey(vals));
} |
5c688273-85f9-4962-a961-4b90d579bb85 | public List<Integer> getIndex(String... vals) {
return getIndex(buildKey(vals));
} |
ef7bc28b-d441-4e75-a853-bcac0d77c005 | public List<Row> getRows(Key key) {
if (!this.index.containsKey(key))
return null;
return this.table.getRows(this.index.get(key));
} |
85e2aa46-f2f1-42f7-8abd-9a0dff719db8 | public List<Row> getRows(Object... vals) {
return getRows(buildKey(vals));
} |
8ca44264-589e-49e9-9719-8f974b1870c7 | public List<Row> getRows(String... vals) {
return getRows(buildKey(vals));
} |
f9741dfa-bdce-4d59-8734-0e890ae0c227 | public Integer getFirstIndex(Key key) {
if (!this.index.containsKey(key))
return null;
return index.get(key).get(0);
} |
2079233b-183b-43cf-b244-eca2f7105d75 | public Integer getFirstIndex(Object... vals) {
return getFirstIndex(buildKey(vals));
} |
fd88ffe9-951e-4b28-833b-4fe6dc7bbc81 | public Integer getFirstIndex(String... vals) {
return getFirstIndex(buildKey(vals));
} |
ecb86cba-4520-4aae-978b-aef132e81211 | public Row getFirstRow(Key key) {
if (!this.index.containsKey(key))
return null;
return this.table.getRow(index.get(key).get(0));
} |
a8479bd7-9137-4cac-a9b5-79a102955cb1 | public Row getFirstRow(Object... vals) {
return getFirstRow(buildKey(vals));
} |
bf8afdc2-3edb-46a7-9a6a-2b1b1cdadfc6 | public Row getFirstRow(String... vals) {
return getFirstRow(buildKey(vals));
} |
04210470-1263-43c9-9e38-b2cc54cdd6a1 | public Object get(String name) {
return super.get(names.indexOf(name));
} |
20f20dc5-9d04-4b78-bddd-961fa1b7c176 | @SuppressWarnings("cast")
public <T> T get(String name, Class<T> clazz) {
return (T) super.get(names.indexOf(name), clazz);
} |
3af9bbc3-0d3f-4365-aec8-174d9a6973d8 | public void set(String name, Object o) {
super.set(names.indexOf(name), o);
} |
b883289d-4d0d-440e-8cac-7c14301849f9 | @Override
public String toString() {
return "Row " + super.toString();
} |
5859c387-100d-43f6-a709-80b6f0801a30 | public Key add(Object key) {
this.data.add(key);
if (key != null) {
this.hashCode += key.hashCode();
}
return this;
} |
e75d074c-ff94-4c2b-9ce4-acb9d529e8c1 | @Override
public int hashCode() {
return this.hashCode;
} |
0e454043-4134-4690-8bba-46e48e895dc0 | @Override
public boolean equals(Object _other) {
if (_other == null)
return false;
if (!(_other instanceof Key))
return false;
Key other = (Key) _other;
if (other.data.size() != this.data.size())
return false;
for (int i = 0; i < this.data.size(); ++i) {
if (this.data.get(i) == null && other.data.get(i) != null)
return false;
if (this.data.get(i) != null && other.data.get(i) == null)
return false;
if (this.data.get(i) == null && other.data.get(i) == null)
continue;
if (!this.data.get(i).equals(other.data.get(i)))
return false;
}
return true;
} |
f0f1151f-713f-4a63-a5e9-e5807dc5cb18 | @Override
public String toString() {
return "Key " + super.toString();
} |
a90c1ecb-0c6e-4a30-ba64-7010b5ba7937 | public Object build(String value) {
return StringUtils.trimToNull(StringUtils.removeStart(StringUtils.removeEnd(value, "\""), "\""));
} |
86937798-c464-456e-8ae4-2230abacc7bb | public BigDecimal build(String value) {
value = StringUtils.trimToNull(StringUtils.removeStart(StringUtils.removeEnd(value, "\""), "\""));
if (value == null)
return null;
return new BigDecimal(value.replace(",", "."));
} |
a63726ac-daf6-4071-9342-4fe3f2e8f60c | public Double build(String value) {
value = StringUtils.trimToNull(StringUtils.removeStart(StringUtils.removeEnd(value, "\""), "\""));
if (value == null)
return null;
return new Double(value);
} |
9f71a638-26fe-45fc-9d65-6fccddfb69b1 | Object build(String value); |
8bc31dc8-e529-49f7-b3b1-75dc8266da45 | public Integer build(String value) {
value = StringUtils.trimToNull(StringUtils.removeStart(StringUtils.removeEnd(value, "\""), "\""));
if (value == null)
return null;
return new Integer(value);
} |
82344e9b-a88f-44c2-8bb2-b6381fc2bba9 | public void addColumn(String name, ObjectBuilder builder) {
this.colNames.add(name);
this.objectBuilders.add(builder);
} |
aa565ce6-8c7c-42d2-b3fd-ae62f4bc9395 | public String getName(Integer i) {
return this.colNames.get(i);
} |
2f71950d-db22-4654-a139-2c69b20adb13 | public Integer getIndex(String name) {
int i = this.colNames.indexOf(name);
if (i == -1)
throw new RuntimeException("Unknown Column: " + name);
return i;
} |
89cd214d-1167-4a46-86a9-63528d2a1eae | public ObjectBuilder getBuilder(Integer i) {
return this.objectBuilders.get(i);
} |
dd178307-09b3-433c-b220-393d6e842221 | public ObjectBuilder getBuilder(String name) {
return this.objectBuilders.get(getIndex(name));
} |
cd0d6d77-ea01-414b-abf3-3793cd96179a | public Row getRow(Integer i) {
return this.rows.get(i);
} |
c9204e79-5ca8-4435-9bcb-c715e3a65e1d | public List<Row> getRows(List<Integer> is) {
List<Row> rows = new ArrayList<Row>();
for (Integer i : is) {
rows.add(this.rows.get(i));
}
return rows;
} |
6bc0f2cf-6205-43b4-8d23-cdc40de9a373 | @SuppressWarnings("unchecked")
public List<Row> getRows() {
return ListUtils.unmodifiableList(this.rows);
} |
e6be70a2-12ed-4202-b8e6-b95d971b0f0e | public void loadFromFile(File file, String separator, boolean skipFirst) {
try {
BufferedReader in = new BufferedReader(new FileReader(file));
String line;
int irow = -1;
Pattern pattern = Pattern.compile(separator, Pattern.LITERAL);
while ((line = in.readLine()) != null) {
++irow;
if (irow == 0 && skipFirst)
continue;
if (StringUtils.trimToNull(line) == null)
continue;
String[] tokens = pattern.split(line, -1);
int icol = -1;
Row row = new Row();
for (String token : tokens) {
++icol;
if (icol + 1 > this.colNames.size())
break;
row.data.add(this.objectBuilders.get(icol).build(token));
}
row.names = this.colNames;
this.rows.add(row);
}
in.close();
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
} |
a0a9246b-7682-42d4-84c7-2fdab83cbf32 | public Object get(Integer i) {
return this.data.get(i);
} |
26523440-42a7-4f8a-ae68-fa4f2aed87f1 | public <T> T get(Integer i, Class<T> clazz) {
return (T) this.data.get(i);
} |
20e15232-08e1-45ca-8413-bdcf9c33c934 | public void set(Integer i, Object o) {
this.data.set(i, o);
} |
616fc77f-cf0c-455b-aa00-9899e999ffcc | @Override
public String toString() {
StringBuilder sb = new StringBuilder("Data {");
for (Object val : this.data) {
sb.append(val.toString()).append(",");
}
sb.deleteCharAt(sb.length() - 1);
sb.append("}");
return sb.toString();
} |
00bfc83a-24e4-4b45-aa42-6dd1f92d6f19 | @Test
public void test() {
StringObjectBuilder stringBuilder = new StringObjectBuilder();
IntegerObjectBuilder integerBuilder = new IntegerObjectBuilder();
DoubleObjectBuilder doubleBuilder = new DoubleObjectBuilder();
BigDecimalObjectBuilder decimalBuilder = new BigDecimalObjectBuilder();
Table table = new Table();
table.addColumn("C1", stringBuilder);
table.addColumn("C2", integerBuilder);
table.loadFromFile(new File("data/a.csv"), ",", false);
Index idx = new Index(table, "C1");
Set<Key> keys = idx.getKeys();
Assert.assertTrue(keys.contains(idx.buildKey("a")));
Assert.assertTrue(keys.contains(idx.buildKey("b")));
List<Row> rows;
rows = idx.getRows(idx.buildKey("a"));
Assert.assertNotNull(rows);
Assert.assertEquals(2, rows.size());
rows = idx.getRows(idx.buildKey("b"));
Assert.assertNotNull(rows);
Assert.assertEquals(1, rows.size());
rows = idx.getRows(idx.buildKey("c"));
Assert.assertNull(rows);
} |
28a98449-254b-4665-955e-596c0191f637 | public Users findByAll(String parUname); |
364f93f5-ba84-4e60-bb12-44751ee501d5 | public Users findByAll(String parUname) {
Session session=HibernateSessionFactory.getSession();
String hql="from Users u where u.uname=?";
Query query=session.createQuery(hql);
query.setString(0, parUname);
Users u=(Users)query.uniqueResult();
return u;
} |
14b8e481-5b7f-4f68-b82d-0d3f77888c71 | public boolean login(String uname,String upwd){
UsersDAOImp ud=new UsersDAOImp();
Users u=ud.findByAll(uname);
if(u!=null){
if(u.getUpwd().equals(upwd)){
return true;
}
}
return false;
} |
8df16af6-ee6c-4317-8311-35f751ada788 | public Users() {
} |
fd4f2c27-b7f3-47ea-9ba1-524eb92bf47b | public Users(String uname, String upwd) {
this.uname = uname;
this.upwd = upwd;
} |
94b343d1-5ce0-4391-989b-89f4bcc03cbd | public Integer getUsid() {
return this.usid;
} |
44156a59-59bf-4c84-b165-2eed48faaa49 | public void setUsid(Integer usid) {
this.usid = usid;
} |
51bcf707-619a-4e5d-9e51-22033ddc4e46 | public String getUname() {
return this.uname;
} |
d6346a8f-e8ec-4e8b-8981-f1fd92445ec7 | public void setUname(String uname) {
this.uname = uname;
} |
36b6d51d-2ffd-4193-a5e1-e2cd4e582781 | public String getUpwd() {
return this.upwd;
} |
595145e4-85e4-4871-b867-63211c15519f | public void setUpwd(String upwd) {
this.upwd = upwd;
} |
563dd4a4-733d-47d1-88bd-7077d7a3d91d | private HibernateSessionFactory() {
} |
bc6a84a5-a21d-4bde-adec-d19dfa082c71 | public static Session getSession() throws HibernateException {
Session session = (Session) threadLocal.get();
if (session == null || !session.isOpen()) {
if (sessionFactory == null) {
rebuildSessionFactory();
}
session = (sessionFactory != null) ? sessionFactory.openSession()
: null;
threadLocal.set(session);
}
return session;
} |
1bd7b6de-e70e-4464-9506-ea3381c89b19 | public static void rebuildSessionFactory() {
try {
configuration.configure(configFile);
sessionFactory = configuration.buildSessionFactory();
} catch (Exception e) {
System.err
.println("%%%% Error Creating SessionFactory %%%%");
e.printStackTrace();
}
} |
c0096f74-d195-47a6-b7bd-ba6756597b09 | public static void closeSession() throws HibernateException {
Session session = (Session) threadLocal.get();
threadLocal.set(null);
if (session != null) {
session.close();
}
} |
9bd599fb-31d2-46e8-ad83-7f44c5b9b162 | public static org.hibernate.SessionFactory getSessionFactory() {
return sessionFactory;
} |
90924f13-0976-4130-8117-8fa85262b5b9 | public static void setConfigFile(String configFile) {
HibernateSessionFactory.configFile = configFile;
sessionFactory = null;
} |
0e44f81b-62fa-4359-b90c-4323e5f8bf8f | public static Configuration getConfiguration() {
return configuration;
} |
e58ee633-26e1-4fc2-89cf-49001a8cb500 | public static int[][] rotateImage(int[][] image){
int n=image.length;
/*The first step*/
for(int i=0;i<n;i++){
for(int j=0;j<n/2;j++){
image[i][j]=image[i][j]+image[i][n-j-1];
image[i][n-j-1]=image[i][j]-image[i][n-j-1];
image[i][j]=image[i][j]-image[i][n-j-1];
}
}
/*The second step*/
for(int i=0;i<n;i++){
for(int j=0;j<n-i-1;j++){
image[i][j]=image[i][j]+image[n-j-1][n-i-1];
image[n-j-1][n-i-1]=image[i][j]-image[n-j-1][n-i-1];
image[i][j]=image[i][j]-image[n-j-1][n-i-1];
}
}
return image;
} |
75644a6e-5d94-469a-93b1-6f85c8c1d6b2 | public static void main(String args[]){
int[][] image={{1,2,3},{4,5,6},{7,8,9}};
image=rotateImage(image);
System.out.println(image[0][0]+" "+image[0][1]+" "+image[0][2]+" \r"+image[1][0]+" "+image[1][1]+" "+image[1][2]+" \r"+image[2][0]+" "+image[2][1]+" "+image[2][2]);
} |
3a57d57d-01b5-4306-90da-14d401ca0390 | public static boolean isPermutation(String s1, String s2){
/*Firstly, compare their length*/
if(s1.length()!=s2.length())
return false;
/*Then use bitmap to do the counting
* Assume char has a range of 0 to 255*/
int map[] =new int[256];
int length=s1.length();
for(int i=0;i<length;i++){
map[s1.charAt(i)]++;
}
for(int i=0;i<length;i++){
map[s2.charAt(i)]--;
}
/*Check whether they are all zeros*/
for (int i=0;i<256;i++){
if(map[i]!=0)
return false;
}
return true;
} |
2d1d3898-32b5-40a2-83f9-766b06d96f67 | public static void main(String args[]){
/*Runs the test*/
String s1="我们";
String s2="们我";
/*The above has the issue of ArrayIndexOutOfBoundsException until the array is 65535*/
System.out.println(isPermutation(s1,s2));
} |
73b86d02-773a-4829-98ff-306f8fb70658 | public static char[] replaceSpace(char[] str, int length){
int countSpace=0;
for(int i=0;i<length;i++){
if (str[i]==' ')
countSpace++;
}
/*Replace the char from backwards so that the operation does not require extra space*/
/*int finalLength = length + countSpace*2; */
for(int i=length;i>=0&&countSpace>0;i--){
str[i+countSpace *2]=str[i];
if(str[i]==' '){
str[i+countSpace*2]='0';
str[i+countSpace*2-1]='2';
str[i+countSpace*2-2]='%';
countSpace--;
}
}
return str;
} |
47478b04-f969-445d-9734-938503e5b21c | public static void main(String args[]){
/*This is a bad test for it is difficult to construct a char array longer than the string needs */
char[] content="I just want to have a testtesttest==========".toCharArray();
System.out.println(replaceSpace(content,20));
} |
02e7717d-5c0e-4fbc-a213-51331ad7ac2d | public static String compressString(String str){
String output="";
char[] strArray=str.toCharArray();
int startIndex = 0,endIndex=0;
/* while(endIndex <=strArray.length){
if(endIndex==strArray.length||strArray[startIndex]!=strArray[endIndex]){
int tempLen=endIndex-startIndex;
output=output.concat(""+strArray[startIndex]+tempLen);
startIndex=endIndex;
if(endIndex==strArray.length)
break;
}else{
endIndex++;
}
}
想了一下,for 循环在结尾部分的处理应该比while要好看*/
/*while 循环略丑代码...*/
for(endIndex=0;endIndex<strArray.length;endIndex++){
if(strArray[startIndex]!=strArray[endIndex]){
int tempLen=endIndex-startIndex;
output=output.concat(""+strArray[startIndex]+tempLen);
startIndex=endIndex;
}
}
/*Final group is not easy to be merged
* calculate it separately.*/
int tempLen=endIndex-startIndex;
output=output.concat(""+strArray[startIndex]+tempLen);
if(output.length()>str.length())
return str;
return output;
} |
d2acdb5c-6893-4c1d-901c-2593adea7866 | public static void main(String args[]){
System.out.println(compressString("abcdeffffffffeeeeeettttteeeee"));
} |
14f29559-04ac-4ece-bd57-3726c81f94df | public boolean isUnique(String s){
/*Declare a new HashSet*/
HashSet<Character> hs = new HashSet<Character>();
int strLen=s.length();
for(int i=0;i<strLen;i++){
/*Use Java's Hash set to judge whether there is repeating*/
if(! hs.add(s.charAt(i))){
return false;
}
}
return true;
} |
65c8c574-3829-426e-b3a7-95667efee670 | public boolean isUnique2(String s){
/*Firstly sort, then compare
* The string is converted to Array. Not sure whether it satisfies that "No additional data structures"
*/
char[] chars=s.toCharArray();
Arrays.sort(chars, 0, chars.length);
for(int i=0;i<chars.length-1;i++){
if(chars[i]==chars[i+1])
return false;
}
return true;
} |
42d92556-bc3e-480c-a049-a6b7903d1781 | public int[][] zeroSet(int[][] matrix){
int m = matrix.length;
int n = matrix[0].length;
HashSet<Integer> column=new HashSet<Integer>();
HashSet<Integer> row=new HashSet<Integer>();
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
if(matrix[i][j]==0){
column.add(i);
row.add(j);
}
}
}
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
if(column.contains(i)||row.contains(j)){
matrix[i][j]=0;
}
}
}
return matrix;
} |
5c7bc348-0694-4f76-a79e-21cefda1dd4e | public void SendMessage(byte[] messagebyte){
this.message = messagebyte;
System.out.println("Encrypted Message: "+message);
FrmCryptMessage decMsg = new FrmCryptMessage();
decMsg.Decrypt(message);
} |
ec371f94-2309-43f3-b323-b7ed96a67a17 | public Cart(String item, int qty, double price) {
this.item = item;
this.qty = qty;
this.price = price;
} |
378e3654-fd15-4317-b9a7-a2c597a9871a | public static void main(String args[]){
try{
Scanner objScan = new Scanner(System.in);
FrmCryptMessage msgEncryptObj = new FrmCryptMessage();
System.out.println("Enter Message");
System.out.println("============================");
String messageobj = objScan.nextLine();
System.out.println("1-Send Message");
System.out.println("0-Delete Message");
String caseChoice = objScan.nextLine();
switch(Integer.parseInt(caseChoice)){
case 1:
msgEncryptObj.EncryptMessage(messageobj);
break;
case 0:
break;
default:
}
}catch(Exception e){
System.out.println("ERROR!!! "+e.getMessage());
}
} |
f7c70d0b-34db-4f7a-8354-8c75fe8ca0cd | public static void main(String args[]){
System.out.println("Welcome to our Shopping System");
System.out.println("==================================");
Scanner scan = new Scanner(System.in);
boolean more_items = true;
ArrayList<Product> products = new ArrayList<Product>();
while(more_items!=false){
System.out.println("Item");
item = scan.nextLine();
System.out.println("Qty");
qty = Integer.parseInt(scan.nextLine());
System.out.println("Price");
price = Double.parseDouble(scan.nextLine());
products.add(new Product(item, qty, price));
System.out.println("Do you want to add another record?");
System.out.println("1-Yes");
System.out.println("0-No");
more_items = Integer.parseInt(scan.nextLine())==1;
}
Display display = new Display(products);
display.printReceipt();
} |
b6cdaf9b-d1e6-4b6a-bf41-9e0a470ca3f7 | public void Decrypt(byte[] message) {
try{
this.message = message;
decryptedMessage = new String(message);
FrmViewMessage objViewDecryptedMsg = new FrmViewMessage();
objViewDecryptedMsg.ViewDecryptedMessage(decryptedMessage);
}catch(Exception e){
System.out.println("ERROR!!! "+e.getMessage());
}
} |
da079763-f7ab-47eb-8675-a00d8ddc6c17 | public FrmItems() {
} |
7b692ead-4ab7-4832-b40f-1adc7ccf480e | public void Greeting(){
Scanner scanObj = new Scanner(System.in);
String item="", qty="", price="";
boolean input = true;
System.out.println("Please Enter item Bought\n");
System.out.println("========================================");
while(input!=false){
System.out.println("Item");
item = scanObj.nextLine();
System.out.println("Price");
price = scanObj.nextLine();
System.out.println("qty");
qty = scanObj.nextLine();
System.out.println("Next Item??");
System.out.println("0-N0");
System.out.println("1-Yes");
input = Integer.parseInt(scanObj.nextLine())==1;
}
ArrayList<ItemsShopped> items = new ArrayList<ItemsShopped>();
items.add(new ItemsShopped(item,price,qty));
} |
32eec4a5-e3d4-4557-a6cb-ad6e7f5942d3 | public FrmItems(String item, String price, String qty, int total) {
this.item = item;
this.price = price;
this.qty = qty;
this.total = total;
DisplayItem dispObj = new DisplayItem();
dispObj.printListReceipt(item,price,qty,total);
} |
d8650ebd-007f-4f4c-824c-e190fa8364b2 | public static void main(String args[]){
FrmItems objItems = new FrmItems();
objItems.Greeting();
} |
a0ea6f66-32e9-4074-9411-14a2c3e0c723 | public void EncryptMessage(String messageobj) {
try{
this.messageobj = messageobj;
byte[] messagebyte = messageobj.getBytes("US-ASCII");
FrmSendMessage objSend = new FrmSendMessage();
objSend.SendMessage(messagebyte);
}catch(Exception e){
System.out.println("ERROR!!!" +e.getMessage());
}
} |
154a446a-6bc2-48d8-aff5-d5ea8c3ae696 | public void printListReceipt(String item,String price,String qty,int total) {
System.out.println("\nOUTPUT");
System.out.println("============================");
System.out.println("Item\tPrice\tQty\tTotal");
System.out.println(""+item+"\t"+price+"\t"+qty+"\t"+total);
} |
4ed383cb-50b7-4a26-a7da-31e687f9dce5 | public Product(String item, int qty, double price) {
this.item = item;
this.qty = qty;
this.price = price;
ArrayList<Cart> cart = new ArrayList<Cart>();
cart.add(new Cart(item, qty, price));
} |
c67b688b-4db8-4b2c-9257-f16fb17a7425 | public Display(ArrayList<Product> products) {
this.products = products;
} |
631e5843-81fd-406a-b4c9-1c297a712955 | public void printReceipt() {
System.out.println("\nOUTPUT");
System.out.println("============================");
System.out.println("Item\tQty\tPrice");
Iterator<Product> itp = products.iterator();
while(itp.hasNext()){
System.out.println(itp.next());
}
} |
f42f3568-bbe8-40c7-af4e-54e7fdb911cf | public void ViewDecryptedMessage(String decryptedMessage) {
this.decryptedMessage = decryptedMessage;
try{
System.out.println("Decrypted Message: "+decryptedMessage);
}catch(Exception e){
System.out.println("ERROR!!! "+e.getMessage());
}
} |
a8b4588e-1a43-4d04-abbc-d15567d17ea8 | public void EncryptMessage(String messageobj) {
try{
this.messageobj = messageobj;
byte[] messagebyte = messageobj.getBytes("US-ASCII");
FrmSendMessage objSend = new FrmSendMessage();
objSend.SendMessage(messagebyte);
}catch(Exception e){
System.out.println("ERROR!!!" +e.getMessage());
}
} |
e85ac42a-e0dc-4e1d-bc40-d58060007064 | public void Decrypt(byte[] message) {
try{
this.message = message;
decryptedMessage = new String(message);
FrmViewMessage objViewDecryptedMsg = new FrmViewMessage();
objViewDecryptedMsg.ViewDecryptedMessage(decryptedMessage);
}catch(Exception e){
System.out.println("ERROR!!! "+e.getMessage());
}
} |
c03f0aaf-febd-44d9-8092-466da1e8cd9c | public ItemsShopped(String item, String price, String qty) {
this.item = item;
this.price = price;
this.qty = qty;
int total = (Integer.parseInt(qty)*Integer.parseInt(price));
ArrayList<FrmItems> printObj = new ArrayList<FrmItems>();
printObj.add(new FrmItems(item,price,qty,total));
} |
ebd0f0dd-d7f4-4e63-b732-b8934f710f05 | public PeopleAround() throws ClassNotFoundException
{
Class.forName("com.mysql.jdbc.Driver");
Base.open("com.mysql.jdbc.Driver", "jdbc:mysql://localhost:3306/Webber_DB?zeroDateTimeBehavior=convertToNull","root","TuhRealClave");
} |
d3aea4c0-f88d-4d13-b41d-6763f51835f8 | public void listarOpciones()
{
System.out.println("1- Mostrar Clientes.\n2- Agregar Cliente.\n3- Eliminar Cliente\n4- Borrar todos los clientes\n5- Salir");
System.out.print("Opcion: ");
opcion = lector.nextInt();
switch(opcion)
{
case 1:
mostrarClientes();
break;
case 2:
agregarCliente();
break;
case 3:
eliminarCliente();
break;
case 4:
borrarTodosClientes();
break;
case 5:
Base.close();
System.exit(0);
break;
default:
System.out.println("Introduzca un valor valido");
break;
}
} |
c9410067-9a96-42ca-a129-041332af571e | public void borrarTodosClientes()
{
System.out.println("Esta seguro de que quiere borrar todos los clientes? [S]|[N]");
String respuesta = lector.next();
if(respuesta.toLowerCase().equals("s"))
{
Cliente.deleteAll();
System.out.println("\t\t******* Todos los clientes fueron borrados *******");
}
else
{
System.out.println("No se borro ningun cliente");
}
//Volver a la pantalla principal
listarOpciones();
} |
ab082c44-f469-4841-bc62-5c427d544f10 | public void eliminarCliente()
{
System.out.println("-------Borrar Cliente-------\n");
try
{
System.out.print("Introduzca el id del cliente a borrar:");
Cliente cliente = Cliente.findFirst("ID = ?", lector.next());
System.out.println("Esta seguro de que quiere borrar este cliente? [S]|[N]");
String respuesta = lector.next();
String clienteNombre = (String) cliente.get("NOMBRE");
if(respuesta.toLowerCase().equals("s"))
{
cliente.delete();
System.out.printf("\t\t** El cliente %s fue borrado **\n",clienteNombre);
}
else
{
System.out.println("No se borro ningun cliente");
}
}
catch(NullPointerException ex)
{
System.out.println("Ese cliente no existe");
}
finally
{
//Volver a la pantalla principal
listarOpciones();
}
} |
4911941a-8d75-4b9e-af6a-203e69ba5ae3 | public void agregarCliente()
{
Cliente cliente = new Cliente();
System.out.print("Nombre:");
cliente.set("NOMBRE",lector.next());
System.out.print("Apellido:");
cliente.set("APELLIDO",lector.next());
System.out.print("Correo:");
cliente.set("CORREO",lector.next());
System.out.print("Telefono:");
cliente.set("TELEFONO",lector.next());
System.out.print("Direccion:");
cliente.set("DIRECCION",lector.next());
System.out.println();
cliente.saveIt();
//Va a pantalla opciones
listarOpciones();
} |
7270ef51-75a8-461d-89ac-238ecb07776f | public void mostrarClientes()
{
System.out.println("\t\tTodos los clientes\n");
LazyList<Cliente> clientes = Cliente.findAll();
for (Cliente cliente : clientes) {
System.out.printf("\tNombre: %s, ",cliente.get("NOMBRE"));
System.out.printf("Apellido: %s, ",cliente.get("APELLIDO"));
System.out.printf("Correo: %s, ",cliente.get("CORREO"));
System.out.printf("Telefono: %s, ",cliente.get("TELEFONO"));
System.out.printf("Direccion: %s\n\n",cliente.get("DIRECCION"));
System.out.println("\t******************************************************************");
}
//Promtea por la salida
do{
System.out.println("\tEscriba \"volver\"");
key = lector.next();
}while(!key.equals("volver"));
//Volver a la pantalla principal
listarOpciones();
} |
73bc5623-2403-4743-a155-3e3862c04eab | public static void main(String[] args)
{
try
{
PeopleAround people = new PeopleAround();
people.listarOpciones();
}
catch (ClassNotFoundException ex){
System.out.println(ex.getMessage());
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.