http://guides.rubyonrails.org/association_basics.html
- belongs_to : TABLE_NAME
- has_one : TABLE_NAME [:through => :TABLE_NAME]
- has_many : TABLE_NAME [:through => :TABLE_NAME]
- has_and_belongs_to_many : TABLE_NAME [:join_table => :TABLE_NAME]
http://guides.rubyonrails.org/association_basics.html
| def main(): | |
| StNumber, StMark = input('Enter student number and student mark separated by a comma') | |
| StNumber = StNumber.upper() | |
| if len(StNumber)==9 and StNumber[0:6].isalpha() and StNumber[6:].isdigit(): | |
| with open("output.txt", "w") as f: | |
| f.write(StNumber + "," + StMark + "\n") | |
| else: | |
| print("Invalid student number") |
| <?xml version="1.0" encoding="utf-8"?> | |
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
| package="daichan4649.lockoverlay" | |
| android:versionCode="1" | |
| android:versionName="1.0" > | |
| <uses-sdk | |
| android:minSdkVersion="15" | |
| android:targetSdkVersion="17" /> |
| /** | |
| * Service layer that connects/disconnects to the server and | |
| * sends and receives events too. | |
| */ | |
| public interface EventService { | |
| void connect(String username) throws URISyntaxException; | |
| void disconnect(); |
| /** | |
| * Implementation of {@link EventService} which connects and disconnects to the server. | |
| * It also sends and receives events from the server. | |
| */ | |
| public class EventServiceImpl implements EventService { | |
| private static final String TAG = EventServiceImpl.class.getSimpleName(); | |
| private static final String SOCKET_URL = "https://socket-io-chat.now.sh"; | |
| private static final String EVENT_CONNECT = Socket.EVENT_CONNECT; | |
| private static final String EVENT_DISCONNECT = Socket.EVENT_DISCONNECT; |
| /** | |
| * Main interface to listen to server events. | |
| * | |
| */ | |
| public interface EventListener { | |
| void onConnect(Object... args); | |
| void onDisconnect(Object... args); |
| /** | |
| * Main interface for accessing data. It extends EventListener to receive | |
| * incoming events from a remote data source. In this case, a chat server. | |
| */ | |
| public interface DataSource extends EventListener { | |
| void connect(String username) throws URISyntaxException; | |
| void disconnect(); |
| /** | |
| * Remote data source. | |
| * | |
| */ | |
| public class RemoteDataSource implements DataSource { | |
| private static RemoteDataSource INSTANCE; | |
| private static EventService mEventService = EventServiceImpl.getInstance(); | |
| private EventListener mRepoEventListener; |
| /** | |
| * Repository can send events to a remote data source and can listen | |
| * for incoming events from remote data source as well. This bidirectional | |
| * flow of events is what makes the app realtime. | |
| * | |
| * Repository implements {@link DataSource} which can send and receive events. | |
| */ | |
| public class Repository implements DataSource { | |
| private static Repository INSTANCE = null; |
| /** | |
| * Listens to user actions and sends data to remote data source. | |
| * <p> | |
| * Presenter implements EventListener. Whenever the server sends events | |
| * to the Repository, it passes those events to the Presenter via EventListener. | |
| */ | |
| public class ChatPresenter implements ChatContract.Presenter { | |
| @NonNull | |
| private final BaseSchedulerProvider mSchedulerProvider; |