-1
내가 전자 메일 시스템에 대한 코드를 쓰고 있어요 내가 하나의 작은 문제가있는 메소드를 호출하는 방법, 나는 방법을 호출하는 방법을 알아낼 수 없습니다.같은 클래스
주요 방법에 writeAllToFile 메소드를 호출하는 올바른 방법은 무엇입니까?
/** 이 * 작성자 : 여기
/**
* Created by Broomhead0 on 4/11/14.
*/
public class User
{
public String userName; // the name of the user
public Mailbox outbox; // reference to the mailbox of sent messages
public Mailbox inbox; // reference to the mailbox of received messages
// create mailboxes according to the size given as input
public User(String o, int boxsize) {
userName = o;
outbox = new Mailbox(boxsize);
inbox = new Mailbox(boxsize);
}
}
가 메시지 클래스입니다 : 여기
/**
* Created by Broomhead0 on 4/11/14.
*/
import java.util.ArrayList;
public class Userlist
{
ArrayList<User> users; //this is an arraylist that will store references to all users
public Userlist()
{
users = new ArrayList<User>();
}
// find a user in the list based on the username
public User findUser(String username)
{
// iterate through the array; only iterate according to how many users are currently in the array
for (int i = 0; i < users.size(); i++)
{
// access the particular user through users.(i), then get the name,
// and call the equals method on that name to compare it with the input username
if (users.get(i).userName.equals(username)){
return users.get(i);
}
}
// no user found
return null;
}
// add a user to the list; only do so if the user does not yet exist
public void addUser(User u)
{
if (findUser(u.userName) != null) //if there is a match,
System.out.println("User already exists");
else //if there is not match
{
users.add(u); //add the username
}
}
//check if this is correct
//accessors
public User getUser(int i){
return users.get(i);
}
public int getNumUsers(){
return users.size();
}
}
은 사용자 클래스입니다 : 여기
public class MailboxSystemSol{
public static void main (String args[]) throws IOException{
//code is too long to post here
}
public static void writeAllToFile(Userlist ul, User u, Message me){
//code is too long to post here
}
}
는 사용자 목록 클래스 Broomhead0, 4/11/14 당신은 무엇을 시도 - */
public class Message {
// the properties of a message
private String sender;
private String receiver;
private String subject;
private String body;
// all property values are known at creation of the message; so initialize
public Message (String s, String r, String sub, String b)
{
sender = s;
receiver = r;
subject = sub;
body = b;
}
// any nice format of printing the names and the values of the properties will do
public void printMsg()
{
System.out.println("Sender: " + sender);
System.out.println("Receiver: " + receiver);
System.out.println("Subject: " + subject);
System.out.println("Message: " + body);
}
// what follows are basic getter methods
public String getSender()
{
return sender;
}
public String getReceiver()
{
return receiver;
}
public String getSubject()
{
return subject;
}
public String getBody()
{
return body;
}
}
귀하의 질문은 질문을 구걸? 어떻게 당신을 위해 일하지 않습니까? 메소드의 인수로 전달한 UserList, User 및 Message 값은 어디서 얻습니까? 내가 지정해야 죄송합니다 –
는 UserList에, 사용자 및 메시지는 다른 클래스에게 있습니다 – broomhead0
'writeAllToFile (your_UL_argument, your_U_argument, your_ME_argument)' –