View previous topic :: View next topic |
Author |
Message |
Razzledazzzle
Joined: 14 Nov 2005 Posts: 94
|
Posted: Thu Mar 29, 2007 8:37 pm Post subject: dont delete till like 8 please |
|
|
Hey this is some code i need for a big ass test tonight and we can use internet but not like email so i need to post it on here so i can semi cheat lol.
Dont delete this till like 8 tonight please.
switch (ccommand) {
case 'a':
add(comList);
break;
all of those etc
private static void add(ComputerList b)
{
String br, m, o;
Computer c;
c = new Computer(br, m , o);
b.addComputertoList(c);
Know Add/load/Remove/Store
(ComputerList b)
public Computer(String b, String m, String o)
{
Constructors
cBrand = b;
cModel = m;
COS = o;
3 setters and 3 getters
class variables--
prinvate int miDataSize;
ArrayList<Computer> cList;
Default computer list constructor--
public ComputerList()
{
cList = new ArrayList<Computer>();
miDataSize = 0;
Add a computer to the list method---
public boolean add(Computer a)
{
cList.add(a);
miDataSize++;
return true;
}
Remove a comptuer from the list method--
public boolean remove(int a)
{
cList.remove(a);
miDataSize--;
return true;
}
Save the list to a file uses try,catch,and finally----------
public boolean save(String fileName)
{
PrintWriter pw = null;
int i;
Computer a;
try
{
pw = new PrintWriter(new FileWriter(fileName));
pw.println(miDataSize);
for (i = 0, i <miDataSize: i++)
{
a = get(i);
ETC ETC
** Buffered Reader** part same as save and print writer almost
Get Code added here
Know tostring
public String toString()
{
String s;
S = "Computer List /n";
for (int i = o; i>miDataSize; i++) {
s += "[" + i + "] " + cList.get(i)
more to those... |
|
Back to top |
|
|
Aetemius Resident Whore
Joined: 22 Apr 2005 Posts: 825 Location: Raleighwood, North Cackalakie
|
Posted: Thu Mar 29, 2007 8:56 pm Post subject: |
|
|
You are a bobo.
Quote: |
Remove a comptuer from the list method |
And if you cannot spell computer, you may not want to choose a career as a programmer. _________________
Duvyen Deportee
Appotus Dominus |
|
Back to top |
|
|
Razzledazzzle
Joined: 14 Nov 2005 Posts: 94
|
Posted: Thu Mar 29, 2007 9:33 pm Post subject: |
|
|
/**
* Constructor - full initialization of the phone entry
* @param sFName
* @param sLName
* @param sFNumber
*/
public Ephone1(String sFName, String sLName, String sPNumber)
{
firstName = sFName; // use parameters to init. member data
lastName = sLName;
phoneNumber = sPNumber;
ephoneCount++; // increment the count
}
/**
* Constructor - default constructor.
*
*/
public Ephone1()
{
this("FName?", "LName?", "phone #?");
}
public static int getEphoneCount()
{
return ephoneCount;
}
/**
* accessors
*/
public String getFirstName()
{
return firstName;
}
public String getLastName()
{
return lastName;
}
public String getPhoneNumber()
{
return phoneNumber;
}
/**
* mutators
*/
public void setFirstName(String sfName)
{
firstName = sfName;
}
public void setLastName(String slName)
{
lastName = slName;
}
public void setPhoneNumber(String sNumber)
{
phoneNumber = sNumber;
} |
|
Back to top |
|
|
Razzledazzzle
Joined: 14 Nov 2005 Posts: 94
|
Posted: Thu Mar 29, 2007 9:33 pm Post subject: |
|
|
haha career isnt programming man. Just a class i have to take last one of it actually untill i can start learning in the network field area. |
|
Back to top |
|
|
Razzledazzzle
Joined: 14 Nov 2005 Posts: 94
|
Posted: Thu Mar 29, 2007 9:46 pm Post subject: |
|
|
class EphoneList
{
private int miDataSize; // number of elements stored in the list
ArrayList<Ephone1> myList; // resizeable collection class for objects
/** default constructor - create an empty list */
public EphoneList()
{
miDataSize = 0;
myList = new ArrayList<Ephone1>();
}
/**
* add a phone number
*/
public boolean add(Ephone1 pInfo)
{
boolean bReturn; // return from list add method
if (pInfo == null) {
return false;
}
bReturn = myList.add(pInfo);
miDataSize++; // update list size
return true;
}
/** save the list to a file
* @param fileName the name of the file
* @return true is sucessfully opened
*/
public boolean fileSave(String fileName)
{
PrintWriter pw; // output file writer
int i; // loop counter
Ephone1 b; // a single phone reference
try {
pw = new PrintWriter(new FileWriter(fileName));
pw.println(miDataSize);
for (i=0; i<miDataSize; i++) {
b = get(i);
pw.println(b.getFirstName());
pw.println(b.getLastName());
pw.println(b.getPhoneNumber());
}
pw.close();
} catch (IOException e) {
e.printStackTrace();
return false;
}
return true;
}
/** open a new list of phone entries from a file
* @param fileName the name of the file
* @return true if the file is sucessfully opened
*/
public boolean fileOpen(String fileName)
{
myList = new ArrayList<Ephone1>();
BufferedReader br; // buffered file reader
int iSize; // number of records
Ephone1 b;
String strLine; // string buffer to read the file
int i; // loop counter
try {
br = new BufferedReader(new FileReader(fileName));
// data format
// line 1 - number of ephone1 objects
// every three lines: name, radius, boolean
strLine = br.readLine();
iSize = Integer.parseInt(strLine);
if (iSize > 0) {
miDataSize = iSize;
}
for (i=0; i<miDataSize; i++) {
b = new Ephone1();
strLine = br.readLine();
b.setFirstName(strLine);
strLine = br.readLine();
b.setLastName(strLine);
strLine = br.readLine();
b.setPhoneNumber(strLine);
myList.add(i, b);
}
br.close();
} catch (IOException e) {
miDataSize = 0; // reset list
e.printStackTrace(); // display error
return false;
}
return true;
}
/** return the selected phone entry from the list
* @param iIndex the 0 based index of the phone in the list
* @return the selected entry, or null if the phone does not exist
*/
public Ephone1 get(int iIndex)
{
Ephone1 b = null;
b = (Ephone1) myList.get(iIndex); // cast results
return b;
}
/** remove an entry from list
* @param iIndex - the 0 based position of the phone in the list
* @return true if the phone item can be removed
*/
public boolean remove(int iIndex)
{
if (iIndex >= miDataSize) { // only delete an existing element
return false;
}
myList.remove(iIndex);
miDataSize--; // update list size
return true;
}
/** display the object as a string
* @return the formatted String representing the object
*/
public String toString()
{
String s;
int i;
// easy way - it is just not formatted very well
// s = myList.toString();
// the normal way
s = "EphoneList ........\n";
for (i=0; i<miDataSize; i++) {
s += "[" + i + "] " + myList.get(i) + "\n";
}
return s;
}
}
/***************************************************************************
* MyInput - from Liang: a simple console input class in Java
**************************************************************************/
class MyInput
{
public static String readString()
{
String str = " ";
BufferedReader br
= new BufferedReader(new InputStreamReader(System.in), 1);
try {
str = br.readLine();
}
catch (IOException ex) {
System.out.println(ex);
}
return str;
}
public static int readInt()
{
return Integer.parseInt(readString());
}
public static double readDouble()
{
return Double.parseDouble(readString());
}
} |
|
Back to top |
|
|
Razzledazzzle
Joined: 14 Nov 2005 Posts: 94
|
Posted: Thu Mar 29, 2007 9:46 pm Post subject: |
|
|
Ok got this test in like one hour
so i need this up for like 4 more hours then you can delete it. Sorry to use your website btw mandaar but i had no choice homie. |
|
Back to top |
|
|
Nerple
Joined: 22 Apr 2005 Posts: 357 Location: Massachusetts
|
Posted: Fri Mar 30, 2007 2:11 am Post subject: |
|
|
This is painful, what happened to the good days of PM'ing them to yourself, or setting up a website on one of the million free services. _________________
|
|
Back to top |
|
|
Raolf Ling King
Joined: 22 Apr 2005 Posts: 130
|
Posted: Fri Mar 30, 2007 1:38 pm Post subject: |
|
|
is it more painful to try to come up with a reason why you read this thread knowing what it was in the first 3 lines or painful because razzle is a hooker and this is the best place he could think of to put this garbage? _________________
|
|
Back to top |
|
|
Mildane
Joined: 03 Aug 2005 Posts: 49
|
Posted: Mon Apr 02, 2007 2:36 am Post subject: |
|
|
Quote: |
is it more painful to try to come up with a reason why you read this thread knowing what it was in the first 3 lines or painful because razzle is a hooker and this is the best place he could think of to put this garbage?
|
Yes. |
|
Back to top |
|
|
Nerple
Joined: 22 Apr 2005 Posts: 357 Location: Massachusetts
|
Posted: Mon Apr 02, 2007 3:18 am Post subject: |
|
|
Mildane wrote: |
Quote: |
is it more painful to try to come up with a reason why you read this thread knowing what it was in the first 3 lines or painful because razzle is a hooker and this is the best place he could think of to put this garbage?
|
Yes. |
Forest Loop with Flowing Thought I _________________
|
|
Back to top |
|
|
Neosporan
Joined: 29 Jun 2005 Posts: 136 Location: Georgia
|
Posted: Tue Apr 03, 2007 4:44 am Post subject: |
|
|
lol .. least Aete helped you out by finding a spelling error which would've caused you a probably headache later by not catching it yourself! Hope you did well on your test though! _________________ Neosporan Plus
70 Cleric |
|
Back to top |
|
|
Besto
Joined: 22 Apr 2005 Posts: 81 Location: Texas
|
Posted: Sat Apr 14, 2007 7:25 pm Post subject: |
|
|
.NET ... *sigh*
Do they teach you guys to to use real programming languages anymore? |
|
Back to top |
|
|
Nerple
Joined: 22 Apr 2005 Posts: 357 Location: Massachusetts
|
Posted: Sun Apr 15, 2007 1:38 am Post subject: |
|
|
Besto wrote: |
.NET ... *sigh*
Do they teach you guys to to use real programming languages anymore? |
I program on an abacus fool. _________________
|
|
Back to top |
|
|
|